Actionscript Collision Detection
Posted on 2007-03-30
I am creating my own version of Pacman as practice for developing flash games. (It is the first one I've ever tried to make).
I have managed to detect a collision with walls etc using mc1.hitTest(mc2)
If the pacman collides with a wall it stops...
The problem I have is if the pacman is between 2 walls (above and below it or to the left and right of it) I want it to only react to the arrow keys in whic directions it can travel.
I.E. if there is a wall above and below it, I want it to only react to the left and right arrow keys...
Using mc1.hitTest(mc2) the pacman reacts to the keypress and just stops where it is, facing the wall either above or below it...
Is there a way to detect if the pacman will collide with a wall before it reacts to the keypress? (hence disabling the keys which point in a direction which the pacman cannot go)
I tried to explain this as best I can. If you need any more information please ask.
Thanks in advance