Reputation: 491
I've got a problem with SKEmitter. RainParticle.sks is the file, here is the code:
let rainParticle = SKEmitterNode(fileNamed: "RainParticle")
...
rainParticle.position = CGPoint(x: size.width / 2, y: size.height + 10)
addChild(rainParticle)
It works on a simulator, but when I run it on my Iphone 4s, it throws me this error:
2014-11-01 21:31:33.227 AfraidGame[1541:60b] +[SKEmitterNode nodeWithFileNamed:]: unrecognized selector sent to class 0x38c0454c 2014-11-01 21:31:33.232 AfraidGame[1541:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[SKEmitterNode nodeWithFileNamed:]: unrecognized selector sent to class 0x38c0454c'
nodeWithFileNamed - unrecognized selector?
can anyone help?
Upvotes: 0
Views: 297
Reputation: 456
Try this :-) Worked for me using Swift.
let sksPath = NSBundle.mainBundle().pathForResource("RainParticle", ofType: "sks")
let rainParticle: SKEmitterNode = NSKeyedUnarchiver.unarchiveObjectWithFile(sksPath!) as SKEmitterNode
rainParticle.position = CGPoint(x: size.width / 2, y: size.height + 10)
addChild(rainParticle)
Upvotes: 2
Reputation: 119
Specifically init(fileNamed:)
its only Available in iOS 8.0 and later.
Upvotes: 4