I'm kind of new to flash actionscripting. I want to start to include some physics into my flash. I'm starting out simply with a bouncing ball but my code doesn't work as it should.
Code:onClipEvent(load)
{
// 1 meter = 1 pixel
aY = 9.8// Down is positive
t = 0
toff = 0 // offset
vi = 0;
vf = 0;
}
onClipEvent(enterFrame)
{
if(this._y >= _root.ground._y)
{
trace("Hit Ground")
toff = getTimer()/100; //Sets offset
vi = -vf //Reverse velocity
this._y = _root.ground._x //Makes sure ball moves to boundary
}
t = getTimer()/100 - toff; //Everytime ball bounces time resets
this._y += vi*t +.5 * aY * t^2
vf = vi + aY * t
}
