Dirso
19-11-2006 19:42:09
Hi,
I'm not sure if I'm posting the question in the right place, but here is it anyway:
I would like to do a simple CEGUI code that when the user press the "Q" key the game "pauses" and show a question "Would you like to stop the game?" with two options ("Yes": shutdown - "No": continue the game).
Does anyone can help me?
Thanks,
Dirso
Dirso
20-11-2006 12:27:27
Hi,
Just to let you know that I tried to use the "P" key but it does nothing and it looks like it should pause the game.
Thanks,
Dirso.
ceacy
20-11-2006 19:43:53
Foe your original question : you've got to code it by yourself, there is no default behavior for this. Fo example, you could store in your frame listener a boolen "mPaused" ; when a key is pressed, you test if it's 'P', and, if so :
- if mPaused is not currently set, you display a CEGUI sheet with two buttons (quit and return). You'll have to register callbacks to detect if a button is pushed.
- if mPaused is already set to true, you switch back to the game and hide the gui sheet, if any (same behavior as if the "cancel" button was pushed)
You also have to adapt your frameStarted() and frameEnded() methods to test if mPaused is set to true ; if so, you don't do anything in you game which could alter the world (game loop skipped).
Another solution
would be to use a game state system, and to push a "pause" state when p is pressed.
Dirso
20-11-2006 20:47:42
I was trying to use game states, but I had some problems with "my car flying", but looks like i didn't know how to use it and now I'm studing what was wrong.
Thanks for your help,
Dirso