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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.