1-star challenge: an easier way to reset position
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.
Solution
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) ...
Get Getting Started with SpriteKit now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.