Okay, first, you make a new document in Flash.
Now draw your enemy. Make it a MOVIE CLIP. Give it the instance name 'guy' without the ''s.
Now add a second keyframe in the movie clip.
In the first KF, make the enemy a movie clip again. Instance Name it 'run' (without the ''s).
Now make your anim of your enemy running or whatever in the MC.
Now, exit the running MC and go to the second keyframe. Make the guy an MC and Instance name it 'die'. It's obvious why that is!
Now for the coding.
For the Guy MC, give it this code:
onClipEvent (enterFrame) {
speed = 5;
this._x += speed;
}This code makes your enemy run to the right of the screen. Edit the speed if you like.
Now exit the die MC and add this code to it:
onClipEvent (enterFrame) {
speed = 5;
this._x += speed;
}This nuetralises the speed of the guy MC, thus causing the MC to stay where it is.
There is no code for the running MC.
Now, on BOTH of the Keyframes in the guy MC, add the code:
stop ();
Now exit the entire guy MC and give the main MC this code:
onClipEvent (enterFrame) {
speed = -5;
this._x += speed;
}
on (release) {
gotoAndPlay("dead");
}Extra note: If your enemy is a stickman, add another layer in the guy MC and and draw a transparent square, covering the stickman.
Also, feel free to add any sound.
FINAL TIP: Copy and paste your enemy MC to make multiple enemies.
Also, add this code at the beginning of the die frame if you are adding a score feature in your game.
_root.score.text++;
Add this code to and frame of your DIEING MC.
Afterwards, exit the dieing MC and the guy MC.
Now add a dynamic text box to the scene. Instance name it 'score'.
AND THERE YOU ARE! TEST THE MOVIE!
If anything is not working, tell me and I'll try to sort it out. I don't make many tuts these days.
~Raffeh