Sprite Kit / Swift Stars Effect

this is what I would like to achieve:

enter image description here

The stars spawn at random, resizing the small dot image, so the stars appear to be shining at random positions. I just started working with Swift a few weeks ago and I am working on this cool game project, it could be a great feature and I'm sure some of the other users can use and answer this too.

Any ideas?

edit: And it's a shame I'm such a newbie.

+3


source to share


2 answers


Consider the use CAEmitterLayer

registered here . It's pretty straight forward.



If in doubt, I've included SpriteKit, even OpenGL with standard Core Animation, without any problem.

+2


source


Speaking of Sprite-kit, you can now use SKEmitterNode

.

Create a new Xcode file:



enter image description here

let stars : SKEmitterNode = NSKeyedUnarchiver.unarchiveObjectWithFile(NSBundle.mainBundle().pathForResource("stars", ofType: "sks")!) as! SKEmitterNode
stars.position = CGPointMake(CGRectGetMidX(self.frame),CGRectGetMidY(self.frame))
stars.zPosition = 1
self.addChild(stars)

      

+1


source







All Articles