-
charackter running mid air
How do I fix running iin mid air
so when i jump it plays the normal jump animation and when I press right in mid air my char tries to walk and i want to disable that
How do I do that?
-
.
Hi,
I would do the sdame as you have for touching ground, create another boolean var, maybe
var jumping:Boolean = false; inisde the onLoad like the others.
When in mid air set jumping to true, then inside your left and right code usesomething like so
PHP Code:
if (Key.isDown(Key.RIGHT))
{
_xscale = +scale;
_x += speed;
if (!jumping)
{
this.gotoAndStop(2);
}
}
then when character is back on ground set jumping = false
good luck
-
.
HI,
Using the code you already are using, try something like so
PHP Code:
onClipEvent (load) { var ground:MovieClip = _root.ground; var grav:Number = 0; var gravity:Number = 2; var speed:Number = 7; var maxJump:Number = -30; var touchingGround:Boolean = false; var jumping:Boolean = false; scale = _xscale; } onClipEvent (enterFrame) { _y += grav; grav += gravity; while (ground.hitTest(_x, _y, true)) { _y -= gravity; grav = 0; } if (ground.hitTest(_x, _y + 5, true)) { jumping = false; touchingGround = true; } else { jumping = true; touchingGround = false; } if (Key.isDown(Key.RIGHT)) { _xscale = +scale; _x += speed; if (!jumping) { this.gotoAndStop(2); } } if (Key.isDown(Key.LEFT)) { _xscale = -scale; _x -= speed; if (!jumping) { this.gotoAndStop(2); } } if (Key.isDown(Key.UP) && touchingGround) { grav = maxJump; jumping = true; this.gotoAndStop(3); } if (Key.isDown(Key.DOWN)) { this.gotoAndStop(4); } if (ground.hitTest(_x + (_width / 2), _y - (_height / 2), true)) { _x -= speed; } if (ground.hitTest(_x - (_width / 2), _y - (_height / 2), true)) { _x += speed; } if (ground.hitTest(_x, _y - (height), true)) { grav = 3; } }
onClipEvent (keyUp) { this.gotoAndStop(1); }
-
thanks dude too kind
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
|