Lahav
Lahav

Reputation: 791

Rotate an SKShapeNode around an arbitrary point

Is there a way to rotate an SKShapeNode, specifically a rectangle, around some arbitrary point?

I declared my SKShapeNode at the beginning of my gameScene class

var bladeTouch = SKShapeNode()

and set its path to form a rectangle

bladeTouch.path = CGPathCreateWithRect(CGRectMake(0, 0, 60, 198), nil)

However "bladeTouch" only manages to rotate around its bottom left corner, while my intention is to have it rotate around a point on the middle of its bottom edge. How would I go about translating its path so that this is possible?

Upvotes: 1

Views: 485

Answers (1)

rob mayoff
rob mayoff

Reputation: 385610

This would be simplest:

bladeTouch.path = CGPathCreateWithRect(CGRectMake(-30, 0, 60, 198), nil)

Upvotes: 1

Related Questions