Checking number of rotations an object has performed?

In my app I have a wheel that rotates depending on the users touch. Is there anyway to be able to track the number of rotations the wheel has performed? I want an event to be triggered after the wheel as turned 3 times. I tried using: if object.rotation == 1080 then… etc but that didn’t work.

Any ideas?

Might want to try:

if object.rotation \> 1080 then print("DO SOMETHING") end

Without code it’s not known how you’re detecting the rotation of your object, but assuming it’s a Runtime enterFrame listener, it’s possible that (depending on a few other variables of course) the object passes the 1080 value on a frame that isn’t caught by your listener. Checking to see if the rotation is over the 1080 value ensures that the object has reached the rotation “limit”, and gives you ability to stop it’s rotation further (if that’s your desired behavior).

I’d try testing >= instead of ==
It’s highly unlikely for an interactive transformation to reach an exact value.

Thank you both for your advice! It seems to be working now :slight_smile:

local numRotations = object.rotation % 360

Should work for you…

Rob

Might want to try:

if object.rotation \> 1080 then print("DO SOMETHING") end

Without code it’s not known how you’re detecting the rotation of your object, but assuming it’s a Runtime enterFrame listener, it’s possible that (depending on a few other variables of course) the object passes the 1080 value on a frame that isn’t caught by your listener. Checking to see if the rotation is over the 1080 value ensures that the object has reached the rotation “limit”, and gives you ability to stop it’s rotation further (if that’s your desired behavior).

I’d try testing >= instead of ==
It’s highly unlikely for an interactive transformation to reach an exact value.

Thank you both for your advice! It seems to be working now :slight_smile:

local numRotations = object.rotation % 360

Should work for you…

Rob