PDA

View Full Version : Gravity Function



cr125rider
July 17th, 2004, 08:54 PM
I am trying to make a function that has the MC move in a gravitational way. Basically gravity, but just in a function that can be called. Please show me how to make a function and call it in Player 7!

Gravity Function in first frame of _root:

Gravity = function (obj) {
// We calculate the increase of speed
// speedx doesn't change
obj.speedy = obj.speedy+obj.gravity;
// We move the ball
obj._x += obj.speedx/5;
obj._y += obj.speedy/5;
if (false) {
obj._y = obj.floor;
obj.speedy *= -obj.bounce;
}
};


Code that loops in main character's 2nd frame. ( Vars used above are defined first frame):

Gravity(this);

Can you find my fatal error?

Thanks in advance,

dangerskew
July 17th, 2004, 09:09 PM
You should have:

_root.Gravity(this);

cr125rider
July 17th, 2004, 09:10 PM
Thank You, Thank You, Thank You! Works perfectly!

Gupps
July 19th, 2004, 11:07 PM
hi is it possible for you to post your fla so that i can see what you mean. I am curious