Object Acceleration (Game Making)
This Tutorial Teach you How to give acceleration to an object
xspeed=1;
yspeed=1;
acc=1;
_root.onEnterFrame=function()
{
if(Key.isDown(Key.LEFT))
{
xspeed-=acc;
}
else if(Key.isDown(Key.RIGHT))
{
xspeed+=acc;
}
if(Key.isDown(Key.UP))
{
yspeed-=acc;
}
else if(Key.isDown(Key.DOWN))
{
yspeed+=acc;
}
ball_mc._x+=xspeed;
ball_mc._y+=yspeed;
}
xspeed=1;
yspeed=1;
acc=1;
_root.onEnterFrame=function()
{
if(Key.isDown(Key.LEFT))
{
xspeed-=acc;
}
else if(Key.isDown(Key.RIGHT))
{
xspeed+=acc;
}
if(Key.isDown(Key.UP))
{
yspeed-=acc;
}
else if(Key.isDown(Key.DOWN))
{
yspeed+=acc;
}
ball_mc._x+=xspeed;
ball_mc._y+=yspeed;
}
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home