enum state {
case begin, end
}
let nodes = [state.begin : "This is the beginning state",
state.end : "This is the end state"]
nodes[.begin]
Here you’ve created an enum and a dictionary. You can use the state’s values to recover values from a dictionary.
nodes[.begin] will have the value "This is the beginning state". You’ve used .begin as an index (or key) into the dictionary. So nodes[.begin] is actually of type String.
Similarly, gameLayerNodes[.Hud] is of type SKNode, and you’re using .Hud as a key for the dictionary value.
The code gameLayerNodes[.Hud]!.addChild(towerSelectedNode is equivalent to:
let node = gameLayerNodes[.Hud]!
node.addChild(towerSelectedNode)