How do I turn a layer

Get help using Construct 2

Post » Fri Apr 08, 2016 3:30 pm

Hi!

This may sound like a stupid question, but I want to turn a layout (90 degrees per turn).
It works fine, but when it hits 360° it doesn't stop turning.

I guess it's pretty simple, but I stuck here.

Here you can download a capx file
https://www.dropbox.com/s/gco1eyam7gjqfjp/turnLayer.capx?dl=1

If you click the left button, the layer should turn left (-90° of the current angle). On the other side, if you click the right button it should turn right (+90° of the current angle).
For this I'm using a variable called "PlatformAngle" (platforms is the name of the layer).

Thank you guys!
Image Image iTunes: Match3 | Google Play: Match3
B
95
S
33
G
30
Posts: 1,099
Reputation: 27,670

Post » Fri Apr 08, 2016 5:07 pm

Can't run your capx because of custom plugins

I suggest you use the limiting expressions when increasing your variable
Set variable "PlatformAngle" to min(PlatformAngle + 90, 360)
Set variable "PlatformAngle" to max(PlatformAngle - 90, 0)
B
83
S
22
G
15
Posts: 1,039
Reputation: 15,219

Post » Fri Apr 08, 2016 5:18 pm

7Soul wrote:Can't run your capx because of custom plugins

I suggest you use the limiting expressions when increasing your variable
Set variable "PlatformAngle" to min(PlatformAngle + 90, 360)
Set variable "PlatformAngle" to max(PlatformAngle - 90, 0)


Hi!
Thank you for your comment. I removed the custom plugin, now you should be able to open it.
I tried your suggestions, but still on 360° it doesn't stop turning.

THank you!
Image Image iTunes: Match3 | Google Play: Match3
B
95
S
33
G
30
Posts: 1,099
Reputation: 27,670

Post » Fri Apr 08, 2016 6:22 pm

That problem happens because when something rotates to 360 degrees, C2 resets the angle to 0 (because 360º = 0º)

My capx: https://dl.dropboxusercontent.com/u/395 ... 81%29.capx

I fix this by saying "turn 90 degrees" instead of "turn until you reach the target angle" (because the target angle resets when it reaches 360)
B
83
S
22
G
15
Posts: 1,039
Reputation: 15,219

Post » Fri Apr 08, 2016 6:36 pm

You have the variable PlatformAngle and the expression LayerAngle("platforms") .

At the same moment as PlatformAngle gets capped on 360 (not sure, events are a mess), the expression LayerAngle jumps from 360 to zero. 360° = 0 °. You cant read out the expression to turn, it goes a differend path then the variable. Thats one. On top you handle the right button with an else, and in this case even sunbaiting in Tinerife meets the else condition.

Here you go:
https://
drive.google.com/open?id=0B1SSuCVV8v74Z0cwakw3OG0xU2c
B
33
S
18
G
28
Posts: 2,462
Reputation: 20,888

Post » Fri Apr 08, 2016 6:38 pm

lol @ @7Soul, beating me in a few minutes, mine is obsolute now.
B
33
S
18
G
28
Posts: 2,462
Reputation: 20,888

Post » Sat Apr 09, 2016 4:22 am

7Soul wrote:That problem happens because when something rotates to 360 degrees, C2 resets the angle to 0 (because 360º = 0º)

My capx: https://dl.dropboxusercontent.com/u/395 ... 81%29.capx

I fix this by saying "turn 90 degrees" instead of "turn until you reach the target angle" (because the target angle resets when it reaches 360)


That's great! Thank you for your quick help!

Regards
Andy
Image Image iTunes: Match3 | Google Play: Match3
B
95
S
33
G
30
Posts: 1,099
Reputation: 27,670

Post » Sat Apr 09, 2016 4:24 am

99Instances2Go wrote:You have the variable PlatformAngle and the expression LayerAngle("platforms") .

At the same moment as PlatformAngle gets capped on 360 (not sure, events are a mess), the expression LayerAngle jumps from 360 to zero. 360° = 0 °. You cant read out the expression to turn, it goes a differend path then the variable. Thats one. On top you handle the right button with an else, and in this case even sunbaiting in Tinerife meets the else condition.

Here you go:
https://
drive.google.com/open?id=0B1SSuCVV8v74Z0cwakw3OG0xU2c


Thank you for your help! It's highly appreciated :)
@7Soul have fixed it already

Thank you!

Regards
Andy
Image Image iTunes: Match3 | Google Play: Match3
B
95
S
33
G
30
Posts: 1,099
Reputation: 27,670


Return to How do I....?

Who is online

Users browsing this forum: ezgaming420, marcinkowski, plinkie and 12 guests