Hi,
I’m making a game, and I need my guy to jump. Right now, he jumps, but more appears about 60 pixels higher, and then falls down regularly (i have a working “gravity” effect).
I really need him to progress pixel by pixel instead of just springing around. I’ll attach the SWF so you know what i mean. (press up to jump)
Here’s my jump code:
if (mainOnGround && !leftKeyDown && !rightKeyDown) {
for (i=0;i<jumpHeight;i++) {
mcMain.y -= jumpSpeed;
mainOnGround = false;
}
for (i=0;i<jumpHeight;i++) {
mcMain.y -= (jumpSpeed/2);
}
}
I have my variables set like this:
//whether or not the main guy is standing on something
var mainOnGround:Boolean = false;
//whether or not the main guy is jumping
var mainJumping:Boolean = false;
//the speed of the jump (must be divisable by 2)
var origJumpSpeed:Number = 0.0005;
var jumpSpeed:Number = origJumpSpeed;
//the maximum height of the jump (must be divisable by 2)
var jumpHeight:Number = 1000;
and the framerate at 100FPS
Thanks,
Kale