本文整理汇总了C++中Menu::AddChild方法的典型用法代码示例。如果您正苦于以下问题:C++ Menu::AddChild方法的具体用法?C++ Menu::AddChild怎么用?C++ Menu::AddChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Menu
的用法示例。
在下文中一共展示了Menu::AddChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NewGame
TitleMenuScreen::TitleMenuScreen(void)
: m_background(LOGICAL_SIZE, true)
{
// Initialise the semi-transparent background rectangle
SDL_Rect backgroundRect = {0, 0, LOGICAL_SIZE.x, LOGICAL_SIZE.y};
RenderRectToTexture( m_background.GetTexture(),
&backgroundRect,
0xFF, 0xFF, 0xFF, 0x00);
m_background.SetTarget(&m_imageTarget);
// Initialise the manager
m_menuManager = new MenuManager();
// Front Menu (first seen on start-up)
Menu* frontMenu = new Menu("front");
frontMenu->AddChild(
new NewGame(Coordinates(50, 50)));
frontMenu->AddChild(
new Options(Coordinates(50, 100), this));
frontMenu->AddChild(
new ExitGame(Coordinates(50, 150)));
m_menuManager->AddMenu(frontMenu);
// Options Menu (Graphics, settings, etc.)
Menu* optionsMenu = new Menu("options");
optionsMenu->AddChild(
new FullscreenToggle(Coordinates(50, 50)));
optionsMenu->AddChild(
new ExitGame(Coordinates(50, 150)));
m_menuManager->AddMenu(optionsMenu);
// Return to the front menu from the options menu
optionsMenu->SetParentMenu(frontMenu);
// Set the initial menu
m_menuManager->SetMenu("front");
}
示例2: Resume
PauseScreen::PauseScreen(Game* game)
: m_transparentBlack(LOGICAL_SIZE, true), m_active(false)
{
// Initialise the semi-transparent background rectangle
SDL_Rect backgroundRect = {0, 0, LOGICAL_SIZE.x, LOGICAL_SIZE.y};
RenderRectToTexture( m_transparentBlack.GetTexture(),
&backgroundRect,
0x00, 0x00, 0x00, 0xEE);
m_transparentBlack.SetTarget(&m_imageTarget);
// Initialise the menu manager
m_menuManager = new MenuManager();
// Front Menu (first seen on start-up)
Menu* frontMenu = new Menu("front");
frontMenu->AddChild(
new Resume(Coordinates(50, 50), game));
frontMenu->AddChild(
new Options(Coordinates(50, 100), this));
frontMenu->AddChild(
new ExitGame(Coordinates(50, 150)));
m_menuManager->AddMenu(frontMenu);
// Options Menu (Graphics, settings, etc.)
Menu* optionsMenu = new Menu("options");
optionsMenu->AddChild(
new FullscreenToggle(Coordinates(50, 50)));
m_menuManager->AddMenu(optionsMenu);
optionsMenu->SetParentMenu(frontMenu);
// Test setting the menu by string
m_menuManager->SetMenu("front");
}