I was wondering what the best way to pause my game would be? I've tried everything i can thing of and im not sure where to go next. Java source file is attatched.
Printable View
I was wondering what the best way to pause my game would be? I've tried everything i can thing of and im not sure where to go next. Java source file is attatched.
Sorry, most of us will not open attachments. I hope you can understand why. Please post the code inside of code tags so that we can see what you are trying to do and then we can help you out.
as a general rule I usually have a boolean like is_paused. Then an Action that sets the boolean according to the desired state (generally a toggle for the is_paused flag). Then, anything that would care about the state of the pause flag checks it's condition (such as a movement button clicked to move a sprite).
This allows the rest of the program to continue as normal and only the things that shouldn't work during a paused state are blocked.Code://a call to do something maybe from actionPerformed() from a listener.
if (!is_paused)
{
//do your rad stuff here because the game isn't paused
}
else
{
//of course the default for paused is do nothing but you could have other things happen during
//pause. I like obscuring the screen so no pause cheating.
}
Hope that helps.