View Full Version : Acceleration
gman62191
11-09-2007, 03:05 AM
I would like to know how to have a ball movie clip move around the screen by use of acceleration, not by a set speed.
WASD keys preferred.
For some reason I can't figure it out on my own.
Thanks a million.
how about gradually increasing the speed ? :o
Syllogism
11-09-2007, 07:22 AM
hi
make sure have your mc in the library with the linkage id of ball. change ax and ay for more/less acceloration.
init();
function init()
{
vx = 0;
vy = 0;
ax = 0.2;
ay = 0.2;
attachMovie("ball", "ball", 0);
ball._x = Stage.width / 2;
ball._y = Stage.height / 2;
}
function onEnterFrame(Void):Void
{
if (Key.isDown(65))
{
vx -= ax;
}
else if (Key.isDown(68))
{
vx += ax;
}
if (Key.isDown(87))
{
vy -= ay;
}
else if (Key.isDown(83))
{
vy += ay;
}
ball._x += vx;
ball._y += vy;
}
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.