I am using swift spritekit.
Hi, I have a couple of questions about M_PI, which I recently learnt about. For my game, I have been researching different ways to rotate things. Basically, in my game there are 2 planes "flying" around the center of the screen.
NOTE: When I tried to use M_PI Xcode warned me to use double.pi, which I used to replace M_PI. Are these things the same thing?
I tried to work out how to rotate a plane around the centre of the screen. I found out that the best way to do that was to make that a child to a centre node and then rotate the centre node, using this line of code:
let OrbitCenter = SKAction.rotate(byAngle: CGFloat(-2 * Double.pi), duration: 3.8)
When I took away the Double.pi, the planes moved a lot slower but still rotated in the same way. Why do we need to use Double.pi?
I wanted one of the planes/SKSpriteNodes to be upside down, so I researched and found this:
PlaneBlue.zRotation = CGFloat(16.0)
. Again, when I take away theDouble.pi
, it has the same effect however it is just pointing somewhere else.
Overall, my two questions are, is Double.pi the same as M_PI, but just Double.pi is the new way of using this or are they different. Also, why do we need to use Double.pi/M_PI?
Thank you in advance.