Search code examples
sprite-kitskemitternode

Trouble with SKEmitterNode - doesn't display colors created in sks file


I have the function below to show an emitter. It is supposed to pick which asks file to use for the emitter based upon the color passed into the function. The sks files have been created and named based upon their colors and they display the proper coloring in Xcode.

However when run on the simulator or the device, it does not appear that the coloring from the sks file is honored. No matter what color is passed in, the emitter shows the same particle colors. BTW this is a spark based emitter.

Any ideas what I may be doing wrong?

func showEmitter(theColor:String){
    var ourEmitterName:String?
    switch(theColor) {
        case "black","white":
        ourEmitterName = "blackwhiteemitter"
    default:
        ourEmitterName = "\(theColor)emitter"
    }

    let emitterPath = NSBundle.mainBundle().pathForResource(ourEmitterName, ofType: "sks")

    let thisEmitter:SKEmitterNode = NSKeyedUnarchiver.unarchiveObjectWithFile(emitterPath!) as SKEmitterNode


    thisEmitter.zPosition = SceneLevel.background.rawValue
    self.addChild(thisEmitter)



}

Thanks for your help - Ken


Solution

  • I found the problem. In my emitters I had the Blend Mode set to 'Add'. After I changed it to 'Alpha' everything worked fine.

    Not sure why that solved it, since I don't know to what was 'added' to what.