For some reason my character can’t jump. I’ve spent a good our trying to debug, and still no luck. Can anyone help?
ySpeed = ySpeed + gravity; //increment gravity on player
if (Key.isDown(JUMP) && playerState != "jumping") {
//if the player presses the JUMP key and is not jumping
playerState = "jumping"; //set player's state to jumping
ySpeed = ySpeed - jumpPower; //give player initial thrust when jumping
}
for (var i:Number = 0; i < _parent.groundArray.length; i++) {
//scroll through each ground instance to check if we're touching it
if (_parent[_parent.groundArray*].hitTest(this._x, this._y, true)) {
//if we are touching the ground
playerState = "standing"; //set player's state to standing
}
while (_parent[_parent.groundArray*].hitTest(this._x, this._y, true)) {
//if we are touching the ground
this._y--; //push player up so the player doesn't fall through the ground
ySpeed = 0; //reset player's y-axis speed so player doesn't go through ground
}
if (_parent[_parent.groundArray*].hitTest(this._x, this._y - this[_parent.hitBox]._height + (this._height / 4), true)) {
//if the player's head (top part of player) is touching a platform
ySpeed = gravity; //push player back so player doesn't go through ground
}
}
Thanks for any help!
-Mike