I chose the solution of running two actions in order to recover the initial position because I wanted to introduce you to sequences, but there is an easier and fancier way of achieving the same result. With the knowledge that you have so far, try to get the same results that you got when using a sequence.
The key to this challenge is to use the runAction(_:, completion:)
method so that we can execute the same block of code as that of resetPositionAction
. Go to the initializeWallMovement
method and replace moveWallAction
with the following code:
wall.runAction(moveWallAction, completion: { self.wall.position = CGPoint(x:(self.view!.bounds.size.width/2), y: self.view!.bounds.size.height + self.wall.frame.size.height/2) })
There you are. With this change, you will just execute one action with a completion block associated with it, thus obtaining the same behavior as the one that you got before.