Reputation: 26223
I need to spawn 4 new SKSpriteNodes
(independent not parented) at the corners of an existing sprite. Its pretty basic stuff but I am struggling to find the correct formula, I though I had it but its not working as expected. Could some either point me towards the correct formula or help me out with some guidance on calculating the 4 [x, y] pairs for any given rotation. Much appreciated.
Upvotes: 0
Views: 489
Reputation: 4989
You could use CGPointApplyAffineTransform
along with CGAffineTransformMakeRotation
if you didn't want to do the math yourself. Your math though looks almost right at first glance, I believe you just need to subtract out the center point. So xnew would be (x - x_c) * cos(a) - (y - y_c) * sin(a). Can't test right now so can't be 100% sure.
Upvotes: 1