Flash Tutorial 6: A Moving Character Type 2
This is for action-script 2.0
There are two types of moving character. As I like to classify them, full 2D and semi 2D. This tutorial is for the semi 2D type.
(A popular example being the original Zelda game.
To make it you need the following:
-top view facing forwards (1 frame animation)
-top view facing backwards (1 frame animation)
-top view facing right (we can make it face left with action-script) (1 frame animation)
-top view walking facing forwards (standard 2-3 frames)
-top view walking facing backwards (standard 2-3 frames)
-top view walking facing left (we can make it face right with action-script) (standard 2-3 frames)
-Detect the pressing of the UP key
-Detect the pressing of the Down key
-Detect the pressing of the Left key
-Detect the pressing of the Right key
-Flip the character
-Make the character move left/right/up/down
so, how do we set this up you ask?
First, lets put the animations in order and set up their action-script. In all of your "view facing" animations (use the facing right animation for facing left, so you have the same animations for left and right) (they should only be one frame), put the following script in the first frame:
for facing right:
for facing left:
for facing forward (back of character to you):
for facing backwards (front of character facing you):
Now, you know those 2-3 frames of walking animation you have? places them after the first frame of their corresponding facing directions. For example, the walking right three frames of animation I have would be pasted into the three frames after the first frame of my view facing right frame. Making a total of 4 frames. (Again, make sure facing left and facing right / walking left and walking right animations are the same in everything except the script on the first frame).
At this point you should now really only have 4 animations (yes, two are the same [left and right]. Make a movie-clip called "character" and make 4 blank frames in it. label the frames "right", "left", "up", "down". Now put the 4 animations you have in their corresponding frames. (switching left and right doesn't matter). the animation with your character's back shown goes in "up". The animation where their front is shown goes in the "down".
now, put this script in the "character" movie-clip itself:
_global.walking_speed = 2; //you can change this number to change the walking speed.
this._xscale = 100;
}//end Key down RIGHT
this._xscale = -100;
}//end key down LEFT
}//end Key down UP
}//end key down DOWN
}//end on Clip Event
and you're done!