Forgot Password / Register
Site Statistics
Total Members: 508
Total Tutorials: 242
Newsest User: TEMP
Todays Unique Hits: 74
0 Users 2 Guests Online

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.
TutorialNinja Image

2). Now create a small circle. You can fill it in with anything.
TutorialNinja Image

Here is my circle...
TutorialNinja Image

3). Now we need to convert it into a movie clip. Select the whole of your circle.
TutorialNinja Image

Then in the tool bar click on "Modify->Convert to Symbol" or Press F8...
TutorialNinja Image

A dialog box should appear. In the Name input box type character
TutorialNinja Image

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...
TutorialNinja Image

4). Click on the Movie Clip on the stage/canvas...
TutorialNinja Image

In the Properties panel, change the instance name to character
TutorialNinja Image

5). Now its time to do the Movie Clip's actionscript.

Click on the frame on which your movie clip is on...
TutorialNinja Image

Then open up the Actions panel which should be near the bottom...
TutorialNinja Image

The panel should look something like this and cover most of the screen...
TutorialNinja Image

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.
ilyas-shezad
Views:
1613
Rating:
Posted on Saturday 14th June 2008 at 12:21 AM
ShadowMage
ShadowMage
Work fine, i've updated codes on both for you
Posted on Thursday 12th June 2008 at 09:53 AM
ilyas-shezad
ilyas-shezad
Images should be loading fine now.
Posted on Wednesday 11th June 2008 at 08:10 PM
ShadowMage
ShadowMage
they were working when i validated it.
Posted on Wednesday 11th June 2008 at 07:57 PM
ilyas-shezad
ilyas-shezad
Hmm no there not try going to the links which they are on.
This is strange and i think i no y...
Posted on Wednesday 11th June 2008 at 07:22 PM
darklight19
darklight19
Images are broke