Here’s another old tutorial that I’ve bought over from the previous site, showing you how to create nice and simple 8 directional movement with rotation, handy for top down games such as RPG’s and the like.
I’ll probably carry this tutorial on at a later date to make a full game from it, until then, here’s the old one.
FrozenHaddock Tutorials: 8 Way Movement
In this tutorial, we’re going to create simple, 8-way, top-down movement. This is easy to implement and effective to use.

First, draw what you want to move.
You need to draw it facing upwards for the rotation to work.

Now select your character.

Hit F8, and convert the car to a movie clip.

Open the actions panel for the car.
To do this, select the movie clip and hit F9.

Now, this script creates the 8 way movement.
Unfortunately, this doesn’t make the character rotate.

This needs to be added into the previous script.

And lines need to be added into the existing script.
So, the full script you have on there should be this-
- onClipEvent(load){
- speed=5;
- }
- onClipEvent(enterFrame){
- if(Key.isDown(Key.LEFT)&&Key.isDown(Key.UP)){
- this._x-=speed;
- this._y-=speed;
- this._rotation=315;
- }
- else if(Key.isDown(Key.LEFT)&&Key.isDown(Key.DOWN)){
- this._x-=speed;
- this._y+=speed;
- this._rotation=225;
- }
- else if(Key.isDown(Key.RIGHT)&&Key.isDown(Key.UP)){
- this._x+=speed;
- this._y-=speed;
- this._rotation=45;
- }
- else if(Key.isDown(Key.RIGHT)&&Key.isDown(Key.DOWN)){
- this._x+=speed;
- this._y+=speed;
- this._rotation=135;
- }
- else if(Key.isDown(Key.LEFT)){
- this._x-=speed;
- this._rotation=270;
- }
- else if(Key.isDown(Key.RIGHT)){
- this._x+=speed;
- this._rotation=90;
- }
- else if(Key.isDown(Key.UP)){
- this._y-=speed;
- this._rotation=0;
- }
- else if(Key.isDown(Key.DOWN)){
- this._y+=speed;
- this._rotation=180;
- }
- }
This should produce this
This can be used in many types of games, particularly RPG’s.
discuss this topic to forum
