metadata
Gravity is pretty simple. Ok, say you have a ball MovieClip (ball) and you want to give it some gravity. I’m assuming that the ball will have some velocity (vx, vy : velocity on x and y axis) and a gravity constant (gravity). Here’s the code:
`
var gravity:Number = 0.03;
this.onEnterFrame = function():Void {
//apply gravity to y velocity (pulls down)
ball.vy += gravity;
//move the ball
ball._x += ball.vx;
ball._y += ball.vy;
}
`
|