Rishi
Rishi

Reputation: 419

How can I bend a rectangle in sprite kit

let's imagine I have a SKSprite node. for reference, I will give an example:

let rect = SKSpriteNode(color: UIColor.blue, size: CGSize(width: 50, height: 300))
rect.position.x = self.frame.midX
rect.position.y = self.frame.midY
self.addChild(rect)

so you can imagine it is a thin tall blue rectangle. How would I go about animating the node to bend the middle part from left to right and repeat infinitely?I will provide a image to give a more clear understanding:

start: enter image description here

next frame: enter image description here

next frame: enter image description here

Sorry if the quality of the images is bad. The only thing is that I want it to animate, Otherwise I could have used static images.

Any help would be appreciated, thanks.

Upvotes: 1

Views: 461

Answers (1)

Simone Pistecchia
Simone Pistecchia

Reputation: 2840

Maybe you should use warpGeometry

enter image description here

I don't know if your runforever create a bad performance.

check the documentation

Upvotes: 5

Related Questions