Quantunet.com

My Account

Joins Us
Flash 8 Actionscript 2.0 Knowledgebase
2D Elastic Bounce On Floor With Gravity  

Download .fla

Actionscript

var gravity = 10;
var elasticity = 0.6;
var friction = 0.95;
var floor = 250;
var Vy = 0;
var Vx = 15;

ball_mc._x = 40;
ball_mc._y = 40;

ball_mc.onEnterFrame = function() {

Vy = Vy + gravity;
this._y += Vy/4;

Vx = Vx*friction;
this._x += Vx;

if (this._y > floor) {
this._y = floor;
Vy = -Vy*elasticity;
}
};


© 2008 Quantunet LLC All Rights Reserved | Intellectual Property | Terms of Use | Privacy
Home | About Quantunet | FAQ's | Contact Us