Game Development Reference
In-Depth Information
These two classes are enough to build a minimalistic interactive user interface for
our game.
How it works…
While setting up the user interface, we construct pages and add them to the global
g_GUI object:
g_GUI = new clGUI();
clPtr<clGUIPage> Page_MainMenu = new clPage_MainMenu;
clPtr<clGUIPage> Page_Game = new clPage_Game;
clPtr<clGUIPage> Page_About = new clPage_About;
When the BACK button is tapped upon, the pages backlow looks as follows:
Page_About → Page_MainMenu
Page_Game → Page_MainMenu
Page_MainMenu → exit the application
We set up references to the back-navigation target pages accordingly:
Page_Game->FFallbackPage = Page_MainMenu;
Page_About->FFallbackPage = Page_MainMenu;
g_GUI->AddPage( Page_MainMenu );
g_GUI->AddPage( Page_Game );
g_GUI->AddPage( Page_About );
The main menu page also contains some useful buttons, which will help the player to navigate
between different pages:
Page_MainMenu->AddButton( new clGUIButton( LRect(
0.3f, 0.1f, 0.7f, 0.3f ), "New Game", Page_Game ) );
Page_MainMenu->AddButton( new clGUIButton( LRect(
0.3f, 0.4f, 0.7f, 0.6f ), "About", Page_About ) );
Page_MainMenu->AddButton( new clGUIButton( LRect(
0.3f, 0.7f, 0.7f, 0.9f ), "Exit", NULL ) );
The application starts at the main menu page:
g_GUI->SetActivePage( Page_MainMenu );
The implementations of individual pages are quite straightforward. clPage_About contains
some information, and we only override the Render() method:
class clPage_About: public clGUIPage
{
public:
 
Search WWH ::




Custom Search