Angles in Degrees

Get help using Construct 2

Post » Sun Nov 16, 2014 11:48 pm

Anybody know of a quick way to have an angle displayed as a degree, rather than a minus.

By degree, I mean an arrow facing directly up would be 270, rather than -90. This also means that if an object rotates completely 10 times, rather than returning a result of 3600, I can instead be presented with a 0. So 0 and 360 are exactly the same, and if an object rotates anti-clockwise a single degree, I'll see 359 rather than -1.

Hope I've made sense!!!
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
80
S
12
G
7
Posts: 965
Reputation: 10,750

Post » Mon Nov 17, 2014 12:19 am

This will work where your angle is coming from the angle expression. Where X is your angle and -180 <= X <= 180, using a conditional expression.

Code: Select all
NiceAngle = X > 0 ? X : 360 + X

Which translates equivalently to the statement(not usable, this is just for demonstration purposes):

Code: Select all
NiceAngle = X if X > 0 else (360 + X)
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,116

Post » Mon Nov 17, 2014 12:42 am

Great! I'll give it a go first thing in the morning! I rarely use conditional expressions like this (if ever, thinking about it), so I'll do my best to get this sorted.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
80
S
12
G
7
Posts: 965
Reputation: 10,750


Return to How do I....?

Who is online

Users browsing this forum: jbr190, plinkie, TRMG and 40 guests