Search tutorials
Right,
To build a game, you have to start out by giving two layers, one called character, or man, or the name of the man you are controlling and another layer called layout or background. You can add a 'Actions' layer if you want. Now, on the first keyframe, of any layer add a button, and maybe a nice instruction text on how to play your game.
now, on the next keyframe on the background layer, draw a background.
Then on the character/man layer draw a spot, convert it to a symble, have the behavior 'movie clip' now, back to your movie, add a stop action to that frame, with the background, So that the movie doesn't play whilst you are moving your character.
Now, add the instance name 'man' to your man/character in the properties panel.
Then, add this action to him.
onClipEvent (load) {
moveSpeed = 3;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x += moveSpeed;
} else if (Key.isDown(Key.UP)) {
this._y -= moveSpeed;
} else if (Key.isDown(Key.DOWN)) {
this._y += moveSpeed;
} else if (Key.isDown(Key.LEFT)) {
this._x -= moveSpeed;
}
}
Basically, this means :
When the clip loads 'movespeed' is of 3 pixels. When you enter the frame, if the RIGHT key is down it adds 'movespeed' (3 pixels) X to the man, which makes him move to the right !
If you don't know, X is a left vertical line, adding something to it makes it move to the right.
Y is a horizontal top line, by adding something to it it moves down and vice versa.
Note : movespeed is an imaginary name, you can change it if you change it in all the script, and you can modify 3 to make faster and slower movements.
So, the character can move now, but, have you noticed ?
HE GOES STRAIGHT THROUGH WALLS !
Now, you know what X and Y are, you can understand the script i will tell you in the minute.
Now, convert each limit/border/wall to a symbol, one symbol per wall, give them these instance names, such as wallup, wallright1, walldown3 or wallleft4, The numbers are because their could be a wad of walls.
Now, for the code you will add TO THE CHARACTER :
onClipEvent (enterFrame) {
if (this.hitTest(_this.wallleft)) {
_x = _x+10;
}
}
THIS CODE IS FOR A LEFT BORDER
This code shows that, if you the HitTest is true, it means you have it something, it will add 10 to X, which will make you bounce off.
_____________________________
onClipEvent (enterFrame) {
if (this.hitTest(this.wallup)) {
_y = _y+10;
}
}
THIS CODE IS FOR A TOP BORDER
________________________________
onClipEvent (enterFrame) {
if (this.hitTest(this.walldown)) {
_y = _y-10;
}
}
THIS IS FOR A BOTTOM BORDER
____________________________
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.outsidelimit3)) {
_x = _x-10;
}
}
THIS IS FOR A LEFT BORDER
_____________________________
Now, you have the code for all the borders, how is your man going to go inside a house or something like that.
First, add a Instance name to your first playing frame, so you can recognize it later.
To add a staircase or something to go somewhere else, create a movieclip, which can be a door or stairs, you choose and add this actionscript to IT (not the man) :
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.man)) {
_root.gotoAndStop("inside");
}
}
This basically means :
As you enter the frame, if the stairs (this) hits the man (this._parent.man) it goes to and plays a frame called inside.
*NOTE* : Without the " " it has to be a number, which, i think is 3 (1 : the menu, 2 : the first playing frame and 3 : the second playing frame)
Now you know the basics of an RPG, wait for my next tutorial that covers how to make a money based game, where you can work, buy and rob !
| » Level Basic |
|
Added: 2005-01-02 Rating: 3 Votes: 36 |
| » Author |
| Hi, i am an 11 y/o kid that is mad about flash animating. |
| » Download |
| Download the files used in this tutorial. |
| Download (0 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!