-
jumping
how do i make it so that a movieclip (man) goes up about an inch, slows down and keeps going down until it collides (_root.man.legs.feet) and then stops?
-
Senior Member
You want to use a velocity variable to track the motion. Kind of like this (vy is my velocity variable).
A gravity constant is used to control the rate of falling.
By tweaking both the initial force of the jump (-10 in the example below), and gravity constant (.5 in the example below), you should be able to arrive at something suitable.
code:
kGroundY = 300; // vertical coordinate of ground plane
kGravity = 0.5; // gravity - affects the height of jump and speed of falling
// adjust to taste
MovieClip.prototype.startJump = function(initialForce)
{
this.vy = initialForce;
this.onEnterFrame = function()
{
this.vy += kGravity;
if (this._y + this.vy > kGroundY)
{
this._y = kGroundY;
this.vx = 0;
delete this.onEnterFrame;
}
else
this._y += this.vy;
}
}
man.startJump(-10);
-
where exactly do i put this?
-
leight.com.au
There are many ways to make a character jump. I'm guessing you're wanting to create a type of platformer? Anyway, to find out heaps of different ways to jump, check out the knowledge base at the very top of the games forum
- Leighton
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
|