2 Replies Latest reply on Oct 6, 2010 8:15 AM by antworker

    Rotate object with actionscript?

    antworker Level 1

      Hi,
      I  am working on a car game in flash where you see the car from a top view and you go straight ahead all the time on an endless road.

      The game so far is built in the way that I have a image of a car that's the main car and the road is a image itself that keep switching with another image of the road and when you play it it looks like the car is moving very fast. But actually the car is not moving at all except for when you move it yourself by going right or left.


      When  turning right I do not want the car to simply move to the right, but I also want it to rotate a bit so it looks more realistic when turning.

      So when you press the right key it rotates 5 degrees even if you keep holding it and when you release the button it rotates back quickly.

      So I'm looking simply for a script that fixes it
      Thanks.

       

      Sorry for bad english.

       

      The script I'm using:

       

      onClipEvent(enterFrame) //This
      {
      if(Key.isDown(Key.LEFT))
      {
      this._x -= 14
      }
      if(Key.isDown(Key.RIGHT))
      {
      this._x += 14
      }
      if(Key.isDown(Key.UP))
      {
      this._y -= 14
      }
      if(Key.isDown(Key.DOWN))
      {
      this._y += 14
      }
      }