RUON RUON - 1 year ago 111
iOS Question

How to make animated spritekit background?

I want to make animated space background in my game, i tried using nodes on spritekit "stars nodes" but the game become laggy because of the amount of the stars, is there any program or way to make HD animated background ?

Answer Source

You just need one node for the background ya know.

Basically, you create each frame of your animated background as images. You can put these images into an image atlas in the asset catalogue.

Now, you can add a single sprite node that covers the whole scene as the "background". You just set the texture of the sprite node to the first frame of your animation.

Then, in didMoveToView or some methods like that,

  1. get your image atlas as an SKTextureAtlas object
  2. get each texture in the atlas using textureNamed and put each of them into an [SKTexture]
  3. Now you have the array, you can do something like this:


    SKAction.animateWithtextures(theTexturesYouCreatedInStep2, timePerFrame: 30)

This link might also help you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download