April 8th, 2013, 10:32 AM
-
Homework - Help! character keeps falling through the ground
hi guys, Im creating a flash As2 side scrolling game but my character keeps falling through the ground (whenever it jumps). This is for a university assignment so could someone help me please?!. heres the code
}
jumping = false;
jumpStartSpeed = 20;
currentJumpSpeed = 0;
onEnterFrame = function(){
// cant jump if you already jump
if(Key.isDown(Key.SPACE) && !jumping)
{
jumping = true;
// the velocity in Y is set to 20
currentJumpSpeed = jumpStartSpeed;
}
if(Key.isDown(Key.RIGHT))
char._x += 5;
if(Key.isDown(Key.LEFT))
char._x -= 5;
if(jumping)
{
// "gravity"
currentJumpSpeed--;
char._y -= currentJumpSpeed;
if(char._y > Stage.height)
{
// the char can be below the stage and it will cause bugs...
char._y = Stage.height;
jumping = false;
}
}
}
COULD SOMEBODY PLEASE HELP ME FIX IT!