ForumsProgramming ForumPause menu and codes for keys help

8 4357
HAXALLNOOBS
offline
HAXALLNOOBS
19 posts
Nomad

I was wondering if anyone could help me with making a pause menu and with what number means each key?

  • 8 Replies
rino
offline
rino
27 posts
Nomad

This might help with the number keys
http://www.ascii.cl/

Recklusfire1
offline
Recklusfire1
20 posts
Nomad

as2 or as3?

clipmaster3
offline
clipmaster3
104 posts
Nomad

how to make the pause menu depnds entirely upon how you've set up your game... we can't really help you with that unless you show us a lot of your code.
As for key codes, I assume you are talking about the Key.isDown() function (which I don't use because I believe event listeners are a better programming practice). Note that the key class has several built-in constants, such as Key.LEFT, Key.RIGHT, etc, so if you just want to check if they're using those keys you can do
if(Key.isDown(Key.LEFT)) { /*whatever*/ }
If you want other keys, though, you have to use their specific scan codes, not ascii codes (as rino posted). I think I have a table bookmarked... hold on...
http://www.pcguide.com/ref/kb/group.htm
See how the codes are based on the location of the keys on the keyboard rather than what the key is itself? I think their might be issues with different operating systems, keyboards, drivers, etc that will make it not work on all computers...

clipmaster3
offline
clipmaster3
104 posts
Nomad

Sorry about the double post but it turns out I'm probably wrong about the scan codes thing... though rino is also wrong about the ascii thing. Next time I'll actually do research instead of just assumptions =P

first of all those built in constants were in the Keyboard class, not Key, and secondly, the livedocs say Keyboard has built-in constants for all the keyboard keys... but the alpha-numeric ones are reserved for adobe AIR applications. Try using their values rather than referencing them directly, i.e use 80 instead of Keyboard.P or whatever

http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/ui/Keyboard.html

Recklusfire1
offline
Recklusfire1
20 posts
Nomad

The easiest way to program a pause feature in your game is to have it in mind in the early stages of your game's development.

Here's two easy ways:

1. Have the game run off one single loop:

public function run(){
if(isPaused){
/*Place your pause feature scripts in here. You could bring in a new movieclip, such as pauseScreen, and load it ontop of everything else. */
}
else{
/*Place your normal game functions in here*/
}
}


2. Or you could set your game off a single timer in which all your functions are based off. To pause the game, you would simply use timerName.stop(); and timerName.start(); to resume.

For bringing in a pause menu, you could bring in a MovieClip with everything on it or have flash switch to a particular frame.
Recklusfire1
offline
Recklusfire1
20 posts
Nomad

Note: by the normal game functions, I meant the regular code. You would have to place your other functions on the same elevation that the function run() runs off of.

HAXALLNOOBS
offline
HAXALLNOOBS
19 posts
Nomad

thnx

dank
offline
dank
983 posts
Peasant

Actually rino is right, keyboard keycodes are based on their ASCII values. 65: A, 66: B, 67: C, etc.

Showing 1-8 of 8