NovumCoder
NovumCoder

Reputation: 4627

SpriteKit: How to draw custom shapes without SKShapeNode?

From Apples class reference for SKShapeNode's but also from many developers i hear that using SKShapeNode for drawing custom shapes you want to draw often on the view is a bad idea because it performs bad.

Its true, a simple app with some custom shapes is spiking my CPU up to 80% and using like 80MB RAM (on devices its a bit better).

So then, how do i draw shapes like arrows without using SKShapeNode, because i like the idea to draw with bezierpaths since i do not need to care about display size.

How to draw an arrow with a texture without getting a bad quality, since it would stretch my image when i move my touch stretching the arrow. Doing this with SKShapeNode works perfect but performs bad.

Upvotes: 2

Views: 1301

Answers (1)

Knight0fDragon
Knight0fDragon

Reputation: 16827

You can always have one SKShapeNode node available that you use for creating shapes, and use the path property to design the shape. Then create a texture out of the SKShapeNode from the scenes view with let texture = scene.view.textureFromNode(shapeNode) and place the new texture into an SKSpriteNode

Upvotes: 3

Related Questions