简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM