Actor Facing Direction
PaxPax
Member Posts: 106
I am struggling with this easy issue and have finally decided to let my bruised ego ask for assistance. I have a clock. The small arm of the clock rotates with a touch behaviour. I cannot figure out how to detect when the small are is facing numbers on the clock. For instance, I would like the sound 'three o'clock' to play when the arrow/small arm is facing the three and so on for each number. How do I detect where the arrow/small arm is facing.
Thanks and cheers!!!
Thanks and cheers!!!
Best Answer
-
Socks London, UK.Posts: 12,822@PaxPax
if self.rotation is 90 (for example) than play sound..... to no avail.
I guess because you are making a clock your arms are going clockwise (axiomatically!) - so in GameSaladLand™ going clockwise is actually decreasing the angle (counterintuitively counterclockwise counts up in positive value / clockwise counts down) . . . so:
12:00 is 0°
3:00 is -90° (or +270°)
6:00 is -180° (or +180°)
9:00 is -170° (or +90°)
I've made you a quick demo:
http://www.mediafire.com/?6jx4i7c92ah694t
. . . .
Answers
3 o'clock = 270°
6 o'clock = 180°
9 o'clock = 90°
12 o'clock = 0°
6 o'clock = 180°
9 o'clock = 90°
12 o'clock = 0°
Woh, now my ego is really bruised.
I should have articulated my question in a more concise manner. What is the 'code' for the arm/arrow to recognize its rotation degree---3 o'clock or whatever. I tried...
if self.rotation is 270 (for example) than play sound..... to no avail.
thanks again and as always, Socks, thanks for making me LOL
Thanks again,
There's probably a more efficient way you could do it without that extra rule - (maybe using %360 ?) - but the demo should hopefully give you a few pointers.
floor((12-(self.Rotation-90)/30)%12)
And here is one for minutes:
floor((60-(self.Rotation-90)/6)%60)
Note: the clock hands should point to 0 degrees when drawn --->