ActionScript: Move an object with keyboard with absolute controls

In this tip I will show you how to move an object with keyboard with absolute controls.

See also how to move an object with keyboard relative-camera control.

What is the absolute controls?

The direction of your object will be calculated depending the object orientation. (Biohazard, Micro Machines, Gears of War). This code is very usefull if you design a car game.

How to make an absolute control in Flash?

  • Get the arrow key status (key is up/key is down);
  • Move or rotate the object on enter frame with the new velocity (Left and Right keys: rotate, Up key: forward, Down key: backward);

Download source: www.benoitfreslon.com_Move_an_object_with_keyboard_with_absolute_controls