Here is my code for the character... it seems to be wrong at the jumping part.. He doesnt play the jump animations and he goes through the ground (lik every code I make)
onClipEvent(load){
speed=10; stop(); dir=0;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)){
_x+=speed; gotoAndStop(1); dir=0;
}else if (Key.isDown(Key.LEFT)){
_x-=speed; gotoAndStop(5); dir=1;
}else{
if (dir==0){
gotoAndStop(2);
}else{
gotoAndStop(4);
}
}
}
onClipEvent (load) {
grav_y = 0;
jumping = false;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.SPACE) && !jumping) {
grav_y = 20;
jumping = true;
}
if (jumping == true && dir ==0) {
gotoAndPlay (3);
}
if (jumping == true && dir ==1) {
gotoAndPlay (6);
}
if (jumping == true) {
grav_y -= 1;
if (grav_y<=-10) {
grav_y = -10;
}
this._y -= grav_y;
}
if (_root.ground.hitTest(this._x, this._y+4, true)){
grav_y = 0;
jumping = false;
}
}