PDA

View Full Version : First Person Shooter Tutorial


Scott
12-31-2004, 02:45 PM
Flash First Person Shooter Tutorial

I designed this tutorial for Flash MX 2004

First open a new flash document and im making the size 550x400, you can pick any size you want.
Now go to Insert>New symbol or Ctrl+F8 and make a movie clip name it "enemy MC"(you should try to always make your movie clips labeled with

MC in the name) and in the movie clip draw the enemy with his gun and it dosent need to move yet. Then go back to the main timeline on the

stage and hit Ctrl+L which opens the library, then drag out "enemy MC" to the stage and click it then right click it and select "Edit in

Place" There you make the enemy do something (which should include shooting you) just use the timeline and make a keyframe to do it and make

as many frames as you want. Now on the final thing he does put the code for the frame as follows:

gotoAndPlay(1);

This will make the movieclip frame go back to the first one so he repeats what he did as if he was looping.
Now after the frame with action script make a frame of the enemy dying and you can make it however many frames you want and on the last frame

put the code

stop();

then check to see what frame was it that is the begining of the enemy dying like for me frame 1 - 5 would be the enemy shooting at me then

frame 6 - 10 would be the dying part so i would remeber 6. When you know the number then go back to the main scene and click on the movie

clip of the enemy and put the following code

on (press) {
this.gotoAndPlay("6");
}

Make sure you change the number 6 to the number i told you to remember which is the frame of the enemy dying.
Now before we test it you have to put this in the first frame on the main timeline

stop();

Now you can test it and make sure that you can click on the guy and it will show the correct sequence of him dying.

Next is the aimer, Add a new layer to the main timeline and name it aimer then in that layer draw a aimer and convert it to a movie clip and

call that Aimer MC then right click it and click "Edit" so that its own timeline will come up, now put the center of the aimer over that plus

sign so its directly in the middle of the aimer. Now go back to the main stage and click the Movie clip of the aimer and give it the

following action script

onClipEvent (load) {
Mouse.hide();
}
onClipEvent (enterFrame) {
_x = _root._xmouse;
_y = _root._ymouse;
if (_y>=700) {
_y = 700;
}
}

Change the 700 to whatever the height is of your scene. Now the mouse wont show up and it will only be the aimer that will be exactaly where

the mouse is.

Now that we have the aimer and the enemy set up i will now show you how to add the gun.

Draw a gun and have it like a first person shooter setup so its facing the the scene. Then convert it to a movie clip and call it Gun MC then
right click it and select "Edit" and make 2 more key frames and give the first one with the drawing of the gun in it these actions

stop();

then in the second one draw a spark or flame at the tip of the gun to show it was fired and in the 3rd frame leave the gun so its back in it

normal position. Now go back to the main scene and click the gun and give it these actions

onClipEvent (enterFrame) {
_x = _root._xmouse;
}
onClipEvent (mouseDown) {
play();
}

Now test it and make sure that that aimer is the mouse, that the enemy shoots and loops until you shoot him, and that the gun follows the

aimer.

This is the basics with no sound, health or ammo added yet


If you have any problems then post and ill do my best to help :)

shwaza
12-31-2004, 02:57 PM
wow, i just started reading that, as i have to go now, and be back tomorrow, but i'll read it all through tomorrow :) sounds helpful :)