Hi
I m making a Java Game for school and I need to know and easy and simple way to be able to pause the game when pressing the key ´P´.
Thank You for your Time!
I wrote a game called Canyon which uses the letter 'p' to pause the game.
Should give you some inspirationSee link.
Java Pause
You can either use KeyListener so the program will listen for that key being pressed and then pause it.
Or you can use KeyBinding.
I used Key Listener before and it was relatively straight forward.
I never used KeyBinding but it looks complicated enough.
As for actually pausing the game, I wouldn't be too sure. Some kind of thread perhaps?
Is it character mode or in graphic mode?
I mean is it simple Java Application or Java Applet?
If applet, do read about KeyListener related aspects
Copyright © 2024 1QUIZZ.COM - All rights reserved.
Answers & Comments
Verified answer
I wrote a game called Canyon which uses the letter 'p' to pause the game.
Should give you some inspirationSee link.
Java Pause
You can either use KeyListener so the program will listen for that key being pressed and then pause it.
Or you can use KeyBinding.
I used Key Listener before and it was relatively straight forward.
I never used KeyBinding but it looks complicated enough.
As for actually pausing the game, I wouldn't be too sure. Some kind of thread perhaps?
Is it character mode or in graphic mode?
I mean is it simple Java Application or Java Applet?
If applet, do read about KeyListener related aspects