How do I count rotations?

Get help using Construct 2

Post » Wed Apr 18, 2012 7:07 pm

How do I count rotations of a sprite?

(I want to combine rotation count with time.
The sprite is moved with the cursor buttons and uses a physics behavior)

The idea behind this question is: for example in Excitebike you want to tell the player: "good! You did 2 rotations in 2 seconds!"

B
16
S
5
G
7
Posts: 599
Reputation: 5,000

Post » Wed Apr 18, 2012 8:24 pm

Use a variable and add the angle difference of the sprite to it every tick.

The "AngleDiff()" expression is not satisfactory since it doesn't give the direction of the angle difference (CW or CCW). So I used this method:
http://blog.lexique-du-net.com/index.php?post/Calculate-the-real-difference-between-two-angles-keeping-the-sign

capx:
http://dl.dropbox.com/u/5426011/examples10/total_rotation.capx
B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757

Post » Sun Apr 22, 2012 11:04 am

Thanks, I will try this!
B
16
S
5
G
7
Posts: 599
Reputation: 5,000

Post » Thu Oct 09, 2014 10:50 am

On my way to work...looks promising will let you know many thanks!
B
10
S
2
G
1
Posts: 38
Reputation: 1,721

Post » Thu Oct 09, 2014 10:35 pm

Hey R0J0hound...it took me all of 15 minutes to integrate this into my game and get it to register backwards and forwards 360's(negative and positive).

It was easy to reset the total rotation to zero ready to measure the next flip etc. I can see how i could hold the count to also register 720's etc, but i think i'll just have a fading graphic (bullet behavior)at the completion of each 360 to replace the test text display in the pic.

I never would have thought to use instance variables. Truthfully i also doubt my brain could have come up with the comparison thing either.. You saved me days of head scratching. I salute your most excellent brain and your community spirit. many thanks for your help!
:)
360 counter.jpg
You do not have the required permissions to view the files attached to this post.
B
10
S
2
G
1
Posts: 38
Reputation: 1,721


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 21 guests