Game Interface using States and SubStates



  • Hi,

    I've been learnig Flixel over the past 2 months and starting to get some cool things happening. Thanks to all the HaxeFlixel contributors for all your work to make it possible for me.

    I'm looking to make a better interface for my game with proper menu, options, etc. I want to have a main menu button on the game that switches to the main menu but keeps the PlayState so you can resume play. It will act as a pause game.

    Should I have the main menu be the only FlxState, and all others FlxSubState?

    Something like:

    MenuState:FlxState
    
    	PlayState:FlxSubState (persistent)
    		VenderState:FlxSubState (I have a vending machine where the player can buy enhancements)
    
    	OptionsState:FlxSubState
    
    	SavedGamesState:FlxSubState
    
    	InstructionsState:FlxSubState
    
    	QuitState:FlxSubState
    
    	GameOverState:FlxSubState
    
    	EtcState:FlxSubState
    

    I'm looking for suggestions and pointers. How would you handle this?



  • If you want to use the so called "FlxSubState" as pause screen I would have only one FlxState. All the other menus would be FlxGroups that gather menu items. Just have a variable like "paused" or something that disabled the update of FlxState when enabled. Menus can have FlxSprite that fills the whole screen and for the player it seems like they stepped out of the game.



  • @IndrekV

    Thanks. I don't necessarily want to use SubState for pause reasons, just wondering how others do it. Most example I've seen are simple and just switch MenuState/PlayState. The main menu is normally first to show, but I also want to be able to access it from the game, so I'm looking for the best way.

    My PlayState creates the different levels from csv data files, so I only have one PlayState that just recreates each new level, or to restart a failed level. The score and some other vars are static so they carry over to the next level. My goal is to have a main menu with "New Game, Saved games, Options, Instructions, Quit", maybe "Resume Game" if one is in progress.

    Maybe I'm not doing things the best way. I'm still on my first game with HF, learning as I go.

    Any suggestions will be appreciated.


Log in to reply
 

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.