Re: Menu
Posted: Mon Feb 23, 2009 9:24 pm
Right now I'm writing a game in C#, so I'm taking advantage of the use of delegates (function pointers). So when I add a menu item, I pass in the function that will execute when it's selected, such as:
In Golvellius, I'm essentially doing the same thing by specifying Lua methods with each menu item - which I prefer, but I'm not using Lua on this game so delegates are a happy medium.
Code: Select all
TitleMenu.MenuItems.Add("Battle Mode",
delegate()
{
TitleMenu.Visible = false;
currentScreen = Screen.CharacterSelection;
InitializeGameMode(GameMode.BattleMode);
startingMatch = true;
gameState = GameState.Running;
});
TitleMenu.MenuItems.Add("Credits",
delegate()
{
TitleMenu.Visible = false;
currentScreen = Screen.Credits;
});
TitleMenu.MenuItems.Add("Quit",
delegate()
{
this.Exit();
});