Assigning different emitters to different nodes that are randomized
<p>I have basic emitter nodes working in my first app. I have created a Constants File that references all nodes throughout my game, and converts them to strings. Great for a mini data base. Its a basic Whack a Mole Game, except I have 12 different characters.</p>

<p><strong>GameScene Code</strong></p>

<p>This is called in my <code>didMoveToView</code> method:</p>

<pre><code> func star(pos: CGPoint) {
        let emitterNode = SKEmitterNode(fileNamed: "star.sks")
        emitterNode!.particlePosition = pos
        self.addChild(emitterNode!)
        self.runAction(SKAction.waitForDuration(2), completion:
            {emitterNode!.removeFromParent() })
    }
</code></pre>

<p>This is called in my <code>touchesDidBegin</code> method:</p>

<pre><code>if node.name == "charEnemy" {             
    let whackSlot = node.parent!.parent as! WhackSlot
    if !whackSlot.visible { continue }
    if whackSlot.isHit { continue }
    star(touchlocation)
    whackSlot.hit()
    ++score
}
</code></pre>

<p>I created my own custom class <code>WhackSlot</code> to handle the <code>charEnemy</code> Node and <code>charFriend</code>:</p>

<pre><code>let name = Barray[Int((RandomFloat(min: 0.0, max: Float(Barray.count))))]
        charNode.texture = SKTexture(imageNamed: name)
        charNode.name = "charFriend"
        charNode.id = name

    } else {
        charNode.texture = SKTexture(imageNamed: Aarray[Int((RandomFloat(min: 0.0, max: Float(Aarray.count))))])
        charNode.name = "charEnemy"
        charNode.id = ""
    }
</code></pre>

<p>I created a custom class for <code>Slot</code>:</p>

<pre><code>import UIKit
import SpriteKit

class Slot: SKSpriteNode {

    var id:String?
}
</code></pre>

<p>So it pulls the data from my constants file where the textures have been converted in strings:</p>

<pre><code>struct Constants {
    struct DEV {
        static let  DEBUG = false
    }

    struct Zoo {

        struct Animal {

            struct DOG {
              static let  NAME = "dog"
               static let IMAGE = "D1" 
            }
            struct DONKEY {
                static let  NAME = "donkey"
                static let IMAGE = "D2"


            }
            struct CAT {
                static let  NAME = "cat"
                static let IMAGE = "D3"
            }

            static let Zoo = [DOG.IMAGE,DONKEY.IMAGE,CAT.IMAGE]

        }
</code></pre>

<p>I have it where Image represents a <code>SKAction</code> that plays a audio file correlating with my constants file. Instead of just giving Stars at the touch location I would like to have each image have its own emitter.</p>

<p>Things I have tried to this point: Endless tutorials, RW, Cartoon Smart. I have the one emitter working, and I can assign a different emitter to <code>charFriend</code> and <code>charEnemy</code> yet I can assign each individual animal their own emitter, I tried adding in the Struct Constants, no dice, I tried if-else statements breaking out each image yet <code>charFriend</code> supersedes it and the same for <code>charEnemy</code>, </p>

<p>This and adding an array of sounds in my Constants for each individual image are my hang ups. </p>

<p>Any suggestions would be helpful. I have hardcoded the game scene, version 2 will be done completely in SpriteKit Scene editor. This is last past of my "Juice" before I submit my first app to App Store. Any guidance would greatly appreciated. </p>

<p>Legacy Eternal. </p>

<p>Latest Software being used. </p>

<p>A little tip I learned a long my journey, if you Make your Game Scene the same size as the Apple TV universal assets @1X optimized for all devices, and for the weird iPad screen just extend your BGNode a little above the parameters and it will automagically convert itself to fit as well. </p>