April 2021
Beginner to intermediate
506 pages
11h 57m
English
The next problem you need to fix is Blob’s inability to switch direction visually. At the moment, Blob only faces in one direction regardless of where he’s headed. You can fix Blob’s misguided behavior using the xScale property of the node.
First, open the Player.swift file and modify the moveToPosition(pos:direction:speed:) method to match the following:
| | func moveToPosition(pos: CGPoint, direction: String, speed: TimeInterval) { |
| | switch direction { |
| | case "L": |
| | xScale = -abs(xScale) |
| | default: |
| | xScale = abs(xScale) |
| | } |
| | |
| | let moveAction = SKAction.move(to: pos, duration: speed) |
| | run(moveAction) |
| | } |
The switch statement evaluates the value in the direction parameter ...
Read now
Unlock full access