user3673836
user3673836

Reputation: 591

Flickering background to Swift Sprite-kit app

I would like to create background of this style to my sprite-kite app written in Swift: https://www.youtube.com/watch?v=o1Fu8GOKGes

but can't think of how that is created. All help to get started is gretly appreciated!

Upvotes: 0

Views: 418

Answers (1)

Christian
Christian

Reputation: 22343

The background of that game is just an atlas of pictures. As you see, the background isn't just one colored. So what the creator did was that he created multiple background-pictures which he then played fast after each other to create that flicker effect. You could try it simple with just colors. Just use SKAction and repeat the action forever:

var white = SKAction.runBlock{
   yourBackgroundNode.color = UIColor.whiteColor()
}

var grey = SKAction.runBlock{
   yourBackgroundNode.color = UIColor.lightGrayColor()
}

self.runAction(SKAction.repeatForever(SKAction.sequence([white, SKAction.waitForDuration(0.5), grey]))

As you see, there are two SKAction blocks which change the color of your background-node to white and grey. You of course can change the color and use an SKTexture instead. If you use it like that, your background-color changes every 0.5 seconds (waitForduration).

Upvotes: 2

Related Questions