pause game.

I haveif(engine.pPressed && !pauseGame){

pauseGame =true;

countergamePause = 10;

}

if(pauseGame){

if(engine.pPressed){

pauseGame =false;

}

return;

}

But that only pauses the game if i hold down the p button. ANy clues why? anyways to pause it?

[675 byte] By [krrose27a] at [2007-11-27 4:32:37]
# 1
That code means nothing to me. You need to give us more.
CaptainMorgan08a at 2007-7-12 9:42:20 > top of Java-index,Other Topics,Java Game Development...
# 2

if(engine.pPressed && !pauseGame){// p is press key event listener is in the engine class & the booleand pause game is no tru the set it true.

pauseGame = true;//pause game

}

if(pauseGame){//if the game is pause

if(engine.pPressed){/if the p is pressed

pauseGame = false;//unpause game

}

return;//else return

}

krrose27a at 2007-7-12 9:42:20 > top of Java-index,Other Topics,Java Game Development...
# 3

I now have

if(pauseGame){

if(engine.pPressed)

pauseGame = false;

return;

}else if(engine.pPressed && !pauseGame){

pauseGame = true;

}

But you know have to click p really fast to unpause .

krrose27a at 2007-7-12 9:42:20 > top of Java-index,Other Topics,Java Game Development...
# 4

I was going to say you needed else if instead of if for the second part, but you found that on your own.

Depending on the OS, Key events can be fired in rapid succession. Typically a quick press of the key gives you 3 key events, a press, type, and release. If you hold it down, you could end up with these events being fired repeatedly. Look at how each of these events is handled, or post that code.

robtafta at 2007-7-12 9:42:20 > top of Java-index,Other Topics,Java Game Development...
# 5
this is how i fixed mine http://forum.java.sun.com/thread.jspa?threadID=5166711&tstart=15
stephensk8sa at 2007-7-12 9:42:20 > top of Java-index,Other Topics,Java Game Development...