Creating a Game - Step 1
Creating a Game - Step 1
Hi and welcome to my flash tutorial.
Its a simple tutorial about how to make a very very very simple game.
Yeh all we are really going to be doing in this tutorial is making a character that can move around a screen.
For this tutorial I will be using Macromedia Flash Professional 8.
The character we are going to be using is going to be a very simple character.
1). First off create a new flash document.
2). Now create a small circle. You can fill it in with anything.
Here is my circle...
3). Now we need to convert it into a movie clip. Select the whole of your circle.
Then in the tool bar click on "Modify->Convert to Symbol" or Press F8...
A dialog box should appear. In the Name input box type
character
Make sure the Type is set to
Movie Clip.
The Registration can be left alone.
Now click Okay. The Movie clip should appear in the library panel...
4). Click on the Movie Clip on the stage/canvas...
In the Properties panel, change the instance name to
character
5). Now its time to do the Movie Clip's actionscript.
Click on the frame on which your movie clip is on...
Then open up the Actions panel which
should be near the bottom...
The panel should look something like this and cover most of the screen...
The above picture is not scaled to full size.
Anyway, carrying on. Copy and paste the following actionscript code into the space provided in the Actions panel...
Code
//ACTIONSCRIPT 2 IS BEING USED
character.onEnterFrame = function() { //ON ENTER FRAME
var speed:Number = 10; //SET A VARIABLE FOR THE SPEED
if (Key.isDown(Key.RIGHT)){ //IF SOMEONE PRESSES DOWN RIGHT
this._x += speed; //MOVE BY 10 ON THE X AXIS
} //END OF STATEMENT
if (Key.isDown(Key.LEFT)){ //IF SOMEONE PRESSES DOWN LEFT
this._x -= speed; //MOVE BY -10 ON THE X AXIS
} //END OF STATEMENT
if (Key.isDown(Key.UP)){ //IF SOMEONE PRESSES DOWN UP
this._y -= speed; //MOVE BY -10 ON THE Y AXIS
} //END OF STATEMENT
if (Key.isDown(Key.DOWN)){ //IF SOMEONE PRESSES DOWN
this._y += speed; //MOVE BY 10 ON THE Y AXIS
} //END OF STATEMENT
} //END THE 'ON ENTER FRAME'
Commented it nicely so you know whats going on.
Your Flash movie should be working now. If you want to test it out you can press Ctrl+Enter or on the toolbar go to Control->Test Movie.
What should my Movie look like if its working
Well, to help you understand how it should be like when its working try looking at what i got...
http://www.ragingmortals.com/tutorials/tutorial_01.html
Fla file...
http://www.ragingmortals.com/tutorials/tutorial_01.fla
I get an actionscript error when I try to test it
Check to see if the code on your Actions panel matches the code that i have provided.
I am lost
Yes I know you are ;)
What will you be doing in Step 2 of this tutorial?
I will be adding in Collision checks.
If you test your movie out now you will notice that he can just walk right off the screen.
This will be fixed in the next tutorial.
I want to make my character move faster!
Okay, Okay no need to shout... Well if you want to change the speed of your character you will need to change the speed variable in the actionscript Code.
I want an answer which is not here...
Post a comment if you would like to know anything else.
Thanks,
If you find any bugs please do report.