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 full 2D type.
(A popular example being the original Mario game.

To make it you need the following:

-right view standing (1 frame)
-right view walking (standard of 3-4 frames)
-right view jumping (standard of 12 frames (tween up and down))
-right view crouching (1 frame)
(there are no left view because action-script can change it's direction dynamically).

Detection Scripts:
-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

Action Scripts:
-Flip the character
-Make the character jump
-Make the character move left/right

so, how do we set this up you ask?

First, make a movie clip for each of the animations (all 4).
Then, Make a new movie clip called "character" and give it the instance name "character". Make 4 blank frames in the "character" movie-clip and put one of the animation movie-clips in each of them. Then put the Stop(); command on all of the 4 frames. Now, label each frame as appropriate to its animation "walking" "standing" "jumping" "crouching".

now It's time for the action-script! (To be placed in the "character" movie-clip).


this._xscale = 100;
this._x += 2;
if(_global.jumping != "yes"){
}//end Key down RIGHT

this._xscale = -100;
this._x -= 2;
if(_global.jumping != "yes"){
}//end key down LEFT

}//end Key down UP

}//end key down DOWN

}//end on Clip Event

Now for the last bit of scripting.

Make sure you put the stop command in the last frame of every animation except "walking";

Now put:

_global.jumping = "yes";
at the first frame of your jumping animation.


[ccN_actionscript]_global.jumping = "no"[/ccN_actionscript]

at the end of your jumping animation.

and you're done!

Be Sociable, Share!