本文整理汇总了C#中Panel.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# Panel.AddChild方法的具体用法?C# Panel.AddChild怎么用?C# Panel.AddChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Panel
的用法示例。
在下文中一共展示了Panel.AddChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateLevelBuildingPanel
public static void GenerateLevelBuildingPanel(ContentManager content)
{
var panelTexture = content.Load<Texture2D>("UiTiles/GrayTileTransparency");
var spriteFont = content.Load<SpriteFont>("Fonts/impact");
var buttonTexture = content.Load<Texture2D>("UiTiles/Button");
var panelPosition = new Vector2(100, 100);
var panelSize = new Rectangle((int)panelPosition.X, (int)panelPosition.Y, 512, 512);
var levelBuilderPanel = new Panel(panelPosition, panelSize, panelTexture);
var levelFiles = FileUtils.GetFilenames("Level");
var levelSelectorObjects = new List<IDrawableGameObject>();
foreach (string levelFile in levelFiles)
{
var objectTexture = content.Load<Texture2D>(levelFile);
var texturedGameObject = new TexturedGameObject(objectTexture);
levelSelectorObjects.Add(texturedGameObject);
}
var objectSelectorTransform = new Transform2D(levelBuilderPanel.Transform);
var level = new Level();
var objectSelector = new ObjectSelector(levelSelectorObjects, objectSelectorTransform, level);
var nextButton = GenerateButton(spriteFont, buttonTexture, "Next", new Vector2(410, 470));
nextButton.OnPress += args => objectSelector.SwitchToNextObject();
var previousButton = GenerateButton(spriteFont, buttonTexture, "Previous", new Vector2(0, 470));
previousButton.OnPress += args => objectSelector.SwitchToPreviousObject();
var placeObjectButton = GenerateButton(spriteFont, buttonTexture, "Place", new Vector2(120, 470));
placeObjectButton.OnPress += args => objectSelector.PlaceGameObjectInLevel();
levelBuilderPanel.AddChild(objectSelector);
levelBuilderPanel.AddChild(previousButton);
levelBuilderPanel.AddChild(nextButton);
levelBuilderPanel.AddChild(placeObjectButton);
Repository.GameObjects.Add(level);
Repository.GameObjects.Add(levelBuilderPanel);
}