|
|||
|---|---|---|---|
|
tutorials game tutorials part 1 -movement |
Beginners tutorial on creating a platform game in AS2 part 1 IntroHey this is a really basic tutorial which is part 1 of a series of tutorials for a complete beginner .this tutorial is on creating movement for a playable character in an rpg/platformer. I won’t be going over animation but i will do in my next tutorial. This is my first tutorial so please if there is any criticisms please send them to my email.alks@live.co.uk. Create Movie ClipFirst of all create a basic circle on the stage by using the oval tool ( O)
Then select the circle by using the selection tool (V).
Now that the circle is selected we want to convert it in to a movie clip so we can play around with it. We can do this by pressing F8.once we do that we can then name the movie clip to what we want in this case name it mc_hero.
Now that the movie clip has been created we can now add code to it ,so we can make it playable Add ActionScript (code) So now if we click on the movie clip we created, so it is selected. Then press F9 the action script window will come up.
Then to allow us to control the character all we do is add the code below in it. Note:the code below is case sensitive eg. “up” is different to “UP” onClipEvent(enterFrame){ if(Key.isDown(Key.UP)){ this._y -= 5; } if(Key.isDown(Key.DOWN)){ this._y += 5; } if(Key.isDown(Key.RIGHT)){ this._x += 5; } if(Key.isDown(Key.LEFT)){ this._x -= 5; } } Code explanationonClipEvent(enterFrame){ } This is basically saying that the code inside { } will be happen each time the game is on the frame. if(Key.isDown(Key.LEFT)){ } This is a IF statement .anything inside the parenthesis is the condition. And if the condition happens whatever inside the {} will happen. this._x -= 5; this is saying that the this will make the movie clip move to the left by 5 in the x direction.it is similar in the y direction but it is reversed.
Then all there is to is to Run it by pressing CTRL + ENTER You should be able to move the circle around with the directional buttons. If not you must have made a mistake so go over the tutorial again. If still in trouble email me i will be glad to help out. Finished productThis is what you should end up with.
|
|
|
|
gorillagames.co.uk copyright 2009
|
|||