That sort of thing (a vector) is easy, once you've determined the direction
in radians, and a speed. Let's call it pixels-per-frame, to make things
simple. Note that this is typed in gmail, and will need tweaks!
accuratePositionX = x;
accuratePositionY = y;
velocityX = Math.cos(direction) * initialVelocity;
velocityY = Math.sin(direction) * initialVelocity;
//Do every frame:
function updatePosition():void
{
accuratePositionX += velocityX;
accuratePositionY += velocityY;
x = Math.round(accuratePositionX);
y = Math.round(accuratePositionY);
velocityX *= 0.9;
velocityY *= 0.9;
if (velocityX < 0.05 && velocityX < 0.05)
stopTheAnimation();
}
Cheers,
-Josh
2009/4/23 flexaustin <[email protected]>
>
>
> Does anyone know of a tutorial on actionscript and gravity. Not like
> dropping a ball, but like google maps where you drag an item and it keeps
> going in that direction but slowing down. So gravity in all directions
> something like a hockey puck.
>
> TIA
>
>
>
--
"Therefore, send not to know For whom the bell tolls. It tolls for thee."
Josh 'G-Funk' McDonald
- [email protected]
- http://twitter.com/sophistifunk
- http://flex.joshmcdonald.info/