0

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

macgeezer
  • 484
  • 1
  • 6
  • 15
  • can you post the code that actually calls this function? Maybe there's something wrong with that. You should log or set a breakpoint to see what parts of the code actually runs. – CodeSmile Feb 07 '15 at 09:18
  • @LearnCocos2D pretty straight forward code. Did use breakpoints. Debugger shows no issues `code` func correctResponse(thisNode:SKNode){ let mySprite = thisNode as Balloon let thisSpriteColor = mySprite.myColor! self.showEmitter(mySprite.myColor!, theSprite: mySprite) ........ } `code` – macgeezer Feb 07 '15 at 13:46

1 Answers1

2

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.

macgeezer
  • 484
  • 1
  • 6
  • 15