I'm working on a pac-man recreation in flash 8, using actionscript 2.0, and i need to makethe controls for pac-man, I want him to move forever when an arrow key is pressed, just like how he does in the original pac-man, so, can anyone give me the code for this?
I tried to find the code that makes pac-man move forever when an arrow key is pressed, but all i found is actionscript 3.0, i'm using actionscript 2.0
If I remember correctly, there are two ways to do it.
First, you can subscribe to the relevant events and record the state of the keys, like that:
Then when there's time for Pacman to act, you can check them:
The second way is to check if the keys are pressed on spot, when it is time for Pacman to perform an action:
The difference between these two is that onKeyDown event is generated perpetually, like if you press a key and get a line of same characters in the text editor: aaaaaaaaaaaaaaaaaaa (but you cannot predict the stroke frequency and the difference between first interval and the rest, as it is controlled by the system), while Key.isDown(...) can be used on spot, if you meter your interactivity with timings, rather then bind it to keypress events.