Post

Replies

Boosts

Views

Activity

Reply to SpriteKit Animations: Moving multiple nodes to different positions in a loop
Here is more detailed code :). I also tried using run(_:completion:) and the same thing happens - the run does not wait for the action to complete before running the completion code. let actionA = SKAction.run { [unowned self] in             var currNodes: [DanceNode] = []                 self.enumerateChildNodes(withName: "draggable") { (node, stop) in                 currNodes.append(node as! DanceNode)             }                 self.formationVM.formationArray = self.formationVM.loadFormations()                 if let nextFormation = self.formationVM.getNextFormation(){                     let nextDancerForms = self.dancerVM.loadNextDancers(nextFormation: nextFormation)         for dancer in nextDancerForms{             if let toUpdateIndex = currNodes.firstIndex(where: { $0.nodeId == dancer.id }) {                 let next = CGPoint(x: CGFloat(dancer.xPos), y: CGFloat(dancer.yPos))                 let action = SKAction.move(to: next , duration: 1.0)                 currNodes[toUpdateIndex].run(action)   }         }                     self.formationVM.currentIndex += 1     }         }             let sequence = SKAction.sequence([actionA, actionA, actionA, actionA])             self.run(sequence) }
Nov ’20