Tutorial 4.2: Setting Up The Menus
Now that we have our menu styles, all we have to do is add the menus. We will create another function for this as well:

public void SetupMenus()
{
        SetMenuStyles();
        // We add a new menu here
        XMenus.AddMenu("Main Menu", "X Engine Demo", ButtonStyle, MainMenuStyle);
        // We add menu buttons here. The first parameter is the text of the button and the other is the name of the button
        XMenus.Menu("Main Menu").AddItem("Start Demo", "Start");
        XMenus.Menu("Main Menu").AddItem("Quit Demo", "Quit");

        XMenus.AddMenu("Pause Menu", "Paused", ButtonStyle, PauseMenuStyle);
        // Note that I use a button name I already used here, we'll see why later
        XMenus.Menu("Pause Menu").AddItem("Continue Demo", "Start");
        XMenus.Menu("Pause Menu").AddItem("Toggle Fullscreen", "Fullscreen");
        XMenus.Menu("Pause Menu").AddItem("Quit Demo", "QuitToMain");

        // Open the main menu and pause the game so that the game will start with the main menu open.
        XMenus.ToggleMenu("Main Menu");
        XGameState.TogglePaused();
}


Now that we have set up the menus, we simply add a call to SetupMenus(); in the Initialize() function. Now that we have setup our menus, all we have left to do is use our input device to control them. Tutorial 4.3: Navigating the menus with input

Last edited Mar 23, 2008 at 7:52 AM by Hazardous101, version 2

Comments

No comments yet.