• Advertisement
Sign in to follow this  

Help with main menu

This topic is 4439 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone. I am trying to do a main menu for my game and had an idea where I had a vector containing all of the objects to be in the first level, and one where I have all of my render objects. At the start of the game the render object vector only contains the menu and when I pressed play I pushed the level1 vectors objects to the render object vector. But unfortunately it doesn´t work. What is a good way to go about creating a menu or any suggestions?

Share this post

Link to post
Share on other sites
To play back how I understand what you've described:

You start your game and have the main screen with all the menu choices.
In clicking one, you want to continue to that screen with all those options.

As an entry level design I would purpose the following:

> Button class - this is just a button that has some text on it and a button look behind it.
> Page class - maybe not the best name, but a class that contains all the 'button' objects for a given menu screen. Perhaps it should be called 'screen' =P

In thinking about how I would want the code to look on the application side of things:
hmm.. how about..

Page mainScreen = new Page();
Button cmdStartGame = new Button( "New game" );
Button cmdOptions = new Button( "Options" );
Button cmdQuit = new Button( "Quit" );

// a delegate or observer pattern here
// - also note these don't have to be separate handlers
// - you could have the object pass itself in to have a switch() setup
cmdStart->onClick( ClickHandlerA );
cmdOptions->onClick( ClickHandlerB );
cmdQuit->onClick( ClickHandlerC );

mainScreen ->addButton( cmdStart );
mainScreen ->addButton( cmdOptions );
mainScreen ->addButton( cmdQuit );


Ok. So that defines one page. The page automatically stacks buttons down the middle of the screen. When you click one, it calls the respective handler to do some kind of code.

So for that I would have class that holds all of this to keep track of what page your on, etc. So you could have code more like:

PageSystem->changePage( "page" ); or PageSystem->changePage( optionsPage );

And in your onClick handlers for a button:
cmdOptions for example:

ClickHandlerB::onClick( /**/ )
// "options" would be precreated and referred by name as one viable option
PageSystem->changePage( "options" );

Three things I would also recommend you check out are the composite, observer and delegate patterns. The first two most especially.

Hope this gives you a few ideas, or if I've wavier to far from what you had in mind, we could get your system working.
Best of luck.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement