13 Replies Latest reply on Sep 23, 2010 6:26 AM by kglad

    Got a problem with a key.IsDown functions.

    Joint3n

      I have a character, more or less looks like a little bug. It's a game, and the goal is for him to walk through a path surrounded by lava.

       

      Now I've got the codes to make him walk, go backwards and turn around.

       

      I've even got a way to make him walking, now I've got a problem..

      I've got a movieclip for him walking, and one for him walking backing up aswell (Sorry if my english is bad)

       

      He walks perfectly, the movieclip for that activates.

      But the movieclip for backing up does not work.

       

      Here is the code:

       

      onClipEvent (load) {

      speed = 5;

      }

      onClipEvent (enterFrame) {

      _x -= speed*Math.sin(_rotation/57.3);

      _y += speed*Math.cos(_rotation/57.3);

      if (Key.isDown(Key.RIGHT)) {

      _rotation += 15;

      }

      if (Key.isDown(Key.LEFT)) {

      _rotation -= 15;

      }

      if (Key.isDown(Key.UP)) {

      this.gotoAndStop(2);

      speed = 5;

      } else {

      speed = 0;

      this.gotoAndStop(1);

      }

      if (Key.isDown(Key.DOWN)) {

      this.gotoAndStop(3);

      speed = -5;

      }

      }

       

      When you press down, he backs up. The movieclip goes to frame three, but it doesn't loop the movieclip, it only stops. So it looks like the figure gets frozen, but still backs up.

       

      What can I do to solve this?