-
making a platform game character jump.
I have a movie clip with 4 labeled frames(jump, idle, walk, run). I have a problem with the jumping.
onClipEvent (load)
{
speed = 7;
isJumping = false;
jumpSpeed = 10;
startY = _y;
}
onClipEvent(enterFrame)
{
if(isJumping)
{
_y += jumpSpeed;
jumpSpeed += 4;
if (_y>+startY)
{
_y = startY;
isJumping = false;
}
if(Key.isDown(Key.UP))
{
gotoAndStop("jump");
isJumping = true;
jumpSpeed = -20;
}
}
}
I want to make it so that if you press up, or accidentally hold up for too long, the character jumps up 20 px and falls back down.
So far, as long as I'm holding up, the character continues to move up.
Any ideas on how to fix this??
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|