3 Replies Latest reply on Nov 3, 2012 2:36 PM by Ned Murphy

    Simple Collision Detection in ActionScript 2?

    CJ C

      I am trying to make a simple maze game, but the collision detection is not working. I have the player moving with the arrow keys, and I am trying to make it so that when the player collides with the wall, it goes to a certain frame. I have this code in the wall movie clip:

       

      onClipEvent (enterFrame) {

      if (_root.player.hitTest(this))

      {

      gotoAndStop("death");

      }

      }

       

      The player's instance name is "player" and the wall's instance name is "walls1". When the player hits the wall, the player just goes right through it. I'm pretty sure it's something with the collision, not the "gotoAndStop("death");" because I tested it with "gotoAndStop(5);" and the player still goes through the wall.

      If someone could help me, I would really appreciate it. Thanks in advance!