Hey, i just have a simple question, how would you write a condition to check the current gamestate.
would it be like?
return app.gamestate==levelone ;
Sorry is this seems really ignorant. Currently I've been assigning a variable to each gamestate, not a different variable just changing the number for one variable, and returning this number when i need to, but i realized that this probably isn't necessary.
Hope someone can help
Check gamestate
Moderator: Moderators
Re: Check gamestate
To implement different states of your game I would recommend to use AppState components - each representing a different state. Then, you probably will not need to check for the game state explicitly, because each AppState can make transition to other states knowing which state is active at the moment of transition. Of course you can have a special variable, e.g. GameState, and set/get its values explicitly:
but this is usually not necessary if you use AppState components.
Code: Select all
// declarations
const int
TitleScreen = 0,
LevelIntro = 1,
Gameplay = 2,
LevelFinished = 3;
int GameState;
// usage in code
GameState = TitleScreen;
...
if(Gameplay == LevelIntro) ...