2
votes

What's the better way to make a coin rotation? I tried Math.random, but the coin doesn't wobble correctly.

starter code

//ROTATION
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
function enterFrameHandler(event:Event):void
{
/*
ADD VELOCITY, GRAVITY, ACCELERATION
*/
coin.rotationY += 8;
}

tried this, but it has no gravity or accelleration

//ROTATION AND RANDOM MATH
function wobble():void {
var wobble = ((Math.random()*4)-2);
flk.rotationY -= 11+wobble/2;
flk.rotationX -= 2+wobble/20;
}
var myInterval:uint = setInterval (wobble, 40);

alt text http://www.ashcraftband.com/myspace/videodnd/coin.jpg

1
if you specify what you're going to use this for it'll be easier to help. is it going to be a simple animation? does it need to be random?grapefrukt

1 Answers

4
votes

The actual maths involved in a spinning coin (or Euler's Disk) is fairly complex, and definitely not random. There's more detail here if you're interested.