1

This is the code I used in iOS 8 to get the particle to appear:

func onCollision() {    
let explosion = SKEmitterNode(fileNamed: "rocketExplosion") 
        explosion.position = rocket.position
        explosion.zPosition = 100
        addChild(explosion) 
}

Worked fine for iOS 8 but not for iOS 9. I've read that there were problems with the particle emitters in the beta, are they still the same in GM version? Also, I tried this after a "Swift 2" tutorial but no luck:

 if let explosion = SKEmitterNode(fileNamed: "rocketExplosion") {
        explosion.position = rocket.position
        explosion.zPosition = 100
        addChild(explosion) }
JGrn84
  • 750
  • 1
  • 9
  • 26
  • Possible duplicate of [SKEmitterNode particleAction not working iOS9 Beta](http://stackoverflow.com/questions/31714076/skemitternode-particleaction-not-working-ios9-beta) – jervine10 Oct 09 '15 at 13:32
  • Possibly a duplication, but this one is for Swift rather than Objective C. – JGrn84 Oct 09 '15 at 18:12

2 Answers2

2

Hopefully this will help you

let explosionFile: String = NSBundle.mainBundle().pathForResource("rocketExplosion", ofType: "sks")!
let explosion = NSKeyedUnarchiver.unarchiveObjectWithFile(explosionFile) as! SKEmitterNode
explosion.position = rocket.position
explosion.zPosition = 100
self.addChild(explosion)
  • 1
    Thanks, I've changed the code to this but it hasn't worked. I'm wondering if its a problem with iOS 9 that they'll sort out? – JGrn84 Sep 22 '15 at 17:39
  • @kellclx I think it may be an iOS 9 problem... I really hope they sort it out soon. – Neel Sarwal Sep 22 '15 at 18:17
0

I had a similar issue while using objective c (so it's not a swift 2 only issue). I found that the particle effects were being rendered behind my background. I've tried setting them on a different Z layer but they still didn't work.

In my experience with iOS 9 if you have a background image it has to be set to at least -1 for particles to work. It seems to only effect my background image. It's able to render the EmitterNodes correctly above all of my other sprites.

Kyle Carruthers
  • 129
  • 1
  • 8