0

I am making a game with the sprite jumping up from the platform. After the jump I have made the sprite to rotate using the angular acceleration. It can rotate clockwise and anticlockwise.

I want to calculate whether it rotated clockwise or anticlockwise before coming to the platform and how many complete revolutions it made.

How it can be done? I am using Phaser 2.3.0.

Kamen Minkov
  • 3,324
  • 1
  • 14
  • 21
user3806026
  • 1
  • 1
  • 1

1 Answers1

0

Look at the documentation for Phaser.Sprite. You have two properties that you may use to achieve what you want: rotation and previousRotation - the current rotation of the sprite and its rotation as it was in the previous render frame, both given in radians. If you override the sprite's update() method, you can check whether its previous angle is (very roughly) 359 degrees and its current angle is 0 (for clockwise rotation) and respectively 1 and 0 for anti-clockwise rotation. In each case like this you can increment a rotation counter. The tricky part would be to come up with a way to round the angles you use for the check, because rotation won't happen in whole angle steps.

Kamen Minkov
  • 3,324
  • 1
  • 14
  • 21