Hey guys, I have a quick question. I followed the platform game tutorial on making an object jump. My problem is that I copied the code exactly the way it is in the tutorial, checked the syntax, edited my character so it fit the script code, but he just won’t jump. Everything in it works except for the jumping part. My code:
onClipEvent (load) {
walkSpeed = 7;
}
onClipEvent (enterFrame) {
if (Key.isDown(key.RIGHT)) {
_x+= walkSpeed; _xscale = 100; gotoAndStop(“run”);
}
if (Key.isDown(key.LEFT)) {
_x-= walkSpeed; _xscale = -100; gotoAndStop(“run”); _xr
}
if (!Key.isDown(key.UP) & !Key.isDown(key.DOWN) & !Key.isDown(key.LEFT) & !Key.isDown(key.RIGHT)) {
tellTarget(this){
gotoAndStop(“idle”);
}}
}
onClipEvent (load) {
jumping = true;
speed = 10;
maxmove = 15;
jump = 0;
}
onClipEvent (enterFrame) {
if (dir == “right”) {
if (speed>0) {
dir = “right”;
} else if (speed<0) {
dir = “left”;
}
if (dir == “right”){
this._x += speed;
_root._x -= speed;
}
if (dir == “left”) {
this._x += speed;
_root._x -= speed;
}
if (Key.isDown(Key.LEFT)) {
if (speed>-maxmove) {
speed–;
}
this.gotoAndStop(“run”);
this._xscale = -100;
} else if (Key.isDown(Key.RIGHT)) {
if (speed<maxmove) {
speed++;
}
this._xscale = 100;
this.gotoAndStop(“run”);
} else if (speed<1 && speed>-1) {
speed = 0;
this.gotoAndStop(“idle”);
}
if (Key.isDown(Key.SPACE) && !jumping) {
jumping = true;
}
if (jumping) {
this.gotoAndStop(“jump”);
this._y -= jump;
jump -= .5;
if (jump<0) {
falling = true;
}
if (jump<-15) {
jump = -15;
}
}
if (_root.ground.hitTest(this._x, this._y, true) && falling) {
jump = 12;
jumping = false;
falling = false;
}
}
}
Any help would be appreciated. Thanks in advance.