Daniel K.
Daniel K.

Reputation: 1556

Creating an efficient tiled background in sprite kit

What I have created in my SpriteKit project is a large two-dimensionally tiled background made up of about 160 sprite nodes. But to me, this seems extremely inefficient.

Would putting these nodes under a single parent make them more efficient? I would assume not and in that case is their a way to combine the textures themselves into a single node at run time?

I would simply use an image editor to tile these images but the size of said background will change between devices, and due to other factors within my project.

Upvotes: 4

Views: 579

Answers (1)

Knight0fDragon
Knight0fDragon

Reputation: 16827

What you can do, in your loading phase, create the 160 sprite nodes needed to make your background under 1 parent node, then call let texture = scene.view.textureFromNode(parentNode), and use this texture for your BG sprite. When the loading phase ends, the 160 sprites should get destroyed

Upvotes: 3

Related Questions