Ok here's a complete platformer tutorial, with, jumping falling, and movement.
1)Draw your player, the ground, some walls to jump over, and some platforms in the air. And spikes beneath the platforms.
2)Make the player a movieclip
Make all the walls a movieclip
Make all the spikes a movieclip
Make the ground and the platforms a movieclip
3)Label the movieclips like this:
The walls > Walls
The ground and platforms > Ground
The spikes > roof
4) Make the movie framerate 20 (Else the movement and stuff will be too slow)
5)And add this long script to the player movieclip:
onClipEvent (load) {
// Set the move speed
moveSpeed = 10;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
if (_root.Walls.hitTest(getBounds(_root).xMax, _y, true)) {
} else {
this._x += moveSpeed;
this.gotoAndStop(3);
}
// Move Right
} else if (Key.isDown(Key.LEFT)) {
if (_root.Walls.hitTest(getBounds(_root).xMin, _y, true)) {
} else {
this._x -= moveSpeed;
this.gotoAndStop(4);
}
// Move Left
}
}
onClipEvent (load) {
grav_y = 0;
jumping = false;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.SPACE) && !jumping) {
vel_y = 36;
jumping = true;
}
if (jumping == true) {
vel_y -= 2;
if (vel_y<=-15) {
vel_y = -15;
}
this._y -= vel_y;
}
if (_root.ground.hitTest(this._x, this._y+27, true)) {
vel_y = 0;
jumping = false;
}
}
onClipEvent (enterFrame) {
this._y += 16;
if (_root.ground.hitTest(this._x, this._y+27, true)) {
this._y -= 16;
}
}
onClipEvent (enterFrame) {
if (_root.roof.hitTest(this._x, this._y-30, true)) {
vel_y = -16;
}
}
Keep posting! Keep Asking!
-EviLudy