1 Reply Latest reply on Feb 21, 2011 3:25 AM by YoshiBoy13

    Starting point for CS5 Movement URGENT

    YoshiBoy13

      I'm using arrow keys to move a spaceship on the background, but nothing seems to be happening. This is the FULL set of code for all directions.

       

      class Ship extends MovieClip

      {

      var velocity;

      velocity = 10

      if (Key.isDown (Key.D)){

      _x+= velocity

      }

      if (Key.isDown (Key.A)){

      _x-= velocity

      }

      if (Key.isDown (Key.W)){

      _y-= velocity

      }

      if (Key.isDown (Key.S)){

      _y-= velocity

      }

      }

       

      Am I doing something wrong?

        • 1. Re: Starting point for CS5 Movement URGENT
          YoshiBoy13 Level 1

          Where should the Velocity = 10 bit be?

          I've modified my code.

          class Ship extends MovieClip

          {var velocity;

          velocity = 10

          if (Key.isDown (Key.D)){_x+= velocity}

          if (Key.isDown (Key.A)){_x-= velocity}

          if (Key.isDown (Key.W)){_y-= velocity}

          if (Key.isDown (Key.S)){_y-= velocity}

          }

           

          Am I doing something wrong? It keeps saying SYNTAX ERROR so I know I must be doing something wrong. I'm just animating something and JUST WANT IT TO MOVE!