I want two different types of nodes to fade there alpha to 0 one after the other (with a sequence). However to find the nodes to fade, I'm using EnumerateChildNodeWithName and there is two of them, so I'm unable (I think) to use a sequence because I would have to use the sequence outside the EnumerateChildNodeWithName (because there is two of them) and at that point, I lose control of the nodes.
Not sure if this makes sense, but here is my code (this fades both types of nodes are the same time):
nodeMovingPlatform1.enumerateChildNodesWithName("*") {
node, stop in
if node.position.x + nodeMovingPlatform1.position.x > self.frame.size.width/2 + node.frame.size.width/2 {
node.removeFromParent()
} else {
if node.name == "landscapeTrigger" {
node.name = "landscape"
node.runAction(actionFadeAlphaTo0_3)
}
}
}
nodeMovingPlatform2.enumerateChildNodesWithName("*") {
node, stop in
if node.position.x + nodeMovingPlatform2.position.x > self.frame.size.width/2 + node.frame.size.width/2 {
node.removeFromParent()
} else {
if node.name == "landscapeTrigger" {
node.name = "landscape"
node.runAction(actionFadeAlphaTo0_3)
}
}
}
The solution to this would be to make use of
SKAction Sequences
, it only runs the second action once the first action is completed.From the Apple Documentation