I have two nodes node1 and node2. node1 is at position 0. when I click on the screen it run its action until its in the middle of the screen or the user removes their finger from the screen. Once node1 reaches the middle of screen it will stop, and node2 will run its action. My code does this so far.
However, in order for node2 to run its action the user must remove their finger from the screen and touch it again. I do not want this to happen. I want the action for node2 to run after node1 finishes without the user removing their finger from screen.
Basically, the user is holding down the screen node1 runs its action finishes and then node2 runs its action.
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
let Node1Move=SKAction.moveBy(x:50,y:0,duration:0.6)
let node1rep=SKAction.repeatForever(Node1Move)
node1.run(node1rep)
if modeNode2==1{
let node2move=SKAction.moveBy(x:-10,y:0,duration:0.9)
let node2Rep=SKAction.repeatForever(node2move)
node2.run(node2Rep)
}
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
node1.removeAllActions()
node2.removeAllActions()
}
override func update(_ currentTime: TimeInterval) {
if node1.position.x+node1.frame.width > self.frame.width/2{
node1.removeAllActions()
moveNode2=1
}
}