|
-
[cs3] Creating a basic Flash platform game, part 1
Creating a basic Flash platform game, part 1
In this tutorial you will be making:
-A main character
-Terrain
TERRAIN
1. Draw your terrain. For this you should probably use a straight, horizontal line.
2. Convert your line into a movie clip.
3. Name it “terrain” (no quotes).
MAIN CHARACTER/AVATAR
1. Draw the body of your character (no legs or arms yet, and no head if you want it animated).
2. Convert it to a movie clip.
3. Name it “man” (no quotes).
4. Double click on the character to edit.
5. Insert the action stop(); on the first frame.
6. Use the next few frames to animate your character walking.
7. Double click on the background to deselect the character.
8. Add these codes to the character.
onClipEvent (load) {
gravity = 0.2; yspeed = 0; xspeed = 1; jumping = 0;
}
onClipEvent (enterFrame) {
if (_root.go) {
if (Key.isDown(Key.LEFT)) {
if (!_root.terrain.hitTest(_x-_width/2, _y+_height/4, true)) {
_x -= xspeed;
}
} if (Key.isDown(Key.RIGHT)) {
if (!_root.terrain.hitTest(_x+_width/2, _y+_height/4, true)) {
_x += xspeed;
}
}if((Key.isDown(Key.UP))(!jumping)){
yspeed = -5; jumping = 1;
} yspeed += gravity; while (_root.terrain.hitTest(_x, _y+_height/2, true)) {
_y--; yspeed = 0; jumping = 0;
} if ((!_root.terrain.hitTest(_x, _y+_height/2+1, true)) or (yspeed<0)) {
_y += yspeed;
} else {
yspeed = 0; jumping = 0;
}
}
} onClipEvent (load) {
scale = _xscale;
} onClipEvent (enterFrame) {
if (key.isdown(key.right)) {
this._x += 10; _xscale = scale; play();
} if (key.isdown(key.left)) {
this._x -= 10; _xscale = -scale; play();
}
}
-
Working On An Online RPG
its an ok tutorial.. but don't you think it would have been better to post on some tutorial website rather than the boards which are mainly to ask questions or to discuss...
nevertheless, it was well explained and people who don't know much about flash could probrably follow it and learn something, so props to you for that
just one concern... you have two onClipEvent(load)'s and two onClipEvent(enterFrame)'s, one of which has the LEFT and RIGHT parts non-capitalised so will never do anything!!!! you should only have one of each, otherwise you are setting a bad example (a big no-no in tutorials)
-
Grimm88,
thanks for the editing problem. i did originally change those, but it probably didn't save.
-
Part 2 to come, I'm working out some technical difficulties
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|