5 Replies Latest reply on Nov 23, 2010 6:23 PM by kglad

# rotation positive and negative numbers

Hi all,

I am creating a roulette type game that calculates the winning number based on the rotation of the main wheel. I am using if/else statements to determine the winning number based on the rotation. I am tracing the rotation in the output panel. I would like my rotation to go from 0-360, but the output panel traces 0-180 then it starts counting from "-180-0"

The wheel can spin multiple times. Any idea how to keep the numbers positive from 0-360 and not have to write my if else to accomodate the negative numbers?

Thanks!

• ###### 1. Re: rotation positive and negative numbers

var rot:Number = (whatever._rotation+360)%360;

• ###### 3. Re: rotation positive and negative numbers

you're welcome.

• ###### 4. Re: rotation positive and negative numbers

Hi kglad, what does the % do?

Thanks!

• ###### 5. Re: rotation positive and negative numbers

that's the modulo operator.  it yields the remainder after removing the largest multiple of b that divides a.

a%b = a - Math.floor(a/b)