Hey guys, I have been working on a sidescroller system and I have the left and right movements done, but I am at a loss as to how I can have him jump and have the gravity kick in. Here is the current code.
onClipEvent (load) {
fallspeed = 8;
platforms = 1;
speed = 5;
falldec = 1.95;
}
onClipEvent (enterFrame) {
fallspeed += falldec;
this._y += fallspeed;
for (i=1; i<=platforms; i++) {
ground = _root["g"+i];
if (this.hitTest(ground)) {
this._y -= fallspeed;
}
}
if (Key.isDown(Key.SPACE) && jumping != true) {
jumping = true;
}
if (jumping == true) {
//What to put here?
}
if(Key.isDown(Key.LEFT)){
this._x -= speed;
this._xscale =-100;
this.gotoAndStop("run");
//_root._x += speed;
}
else if(Key.isDown(Key.RIGHT)){
this._x += speed;
this._xscale =100;
this.gotoAndStop("run");
//_root._x -= speed;
}
else{
this.gotoAndStop("idle");
}
}
The comments about the Root x position are simply to move the stage later on, not sure about them currently though.
I can upload the Fla later If need be, any help is appreciated. Thanks guys