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,