2

I am trying to learn how to use SKEmitterNode, for which I created a SpriteKit project. By default it provides a GameScene.sks file, selecting which it displays a list of objects in library which includes an EmitterNode. I tried to drag EmitterNode over the GameScene and configure it in attribute inspector, which looks like this:

Scene editor with emitter

I tried to run the project on simulator after this simple setup, but it is not showing any particles on the screen, it is showing the default 'Hello World' UI :(

hello world

Is there any thing, which I am missing?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Devarshi
  • 16,440
  • 13
  • 72
  • 125

1 Answers1

0

For example you can create separate file for your EmitterNode (TestNode.sks). In this file you can configure your EmitterNode like you make it in attribute inspector. Then you can add your node to your scene in GameScene.swift file like this:

let emitterPath: String = NSBundle.mainBundle().pathForResource("TestNode", ofType: "sks")!
let emitterNode = NSKeyedUnarchiver.unarchiveObjectWithFile(emitterPath) as SKEmitterNode
emitterNode.position = CGPointMake(100, 100)
emitterNode.name = "emitterNode"
emitterNode.zPosition = 10
emitterNode.targetNode = self
self.addChild(emitterNode)
Alexey Pichukov
  • 3,377
  • 2
  • 19
  • 22
  • 3
    I don't think that answers the question. How would one assign "TestNode.sks" to the particle emitter node already created in "GameScene.sks" ? – Jeff Sep 24 '15 at 06:47
  • I think the "pathForResource" method above pulls in the TestNode. – SSH This Jun 21 '16 at 22:45