April 2021
Beginner to intermediate
506 pages
11h 57m
English
Similar to how you added the numberOfFreeContinues property in Save and Load the Number of Continues, you need to add a property to track the number of paid continues; one that uses a custom getter and setter.
Open the GameScene.swift file, and below the code that adds the numberOfFreeContinues property, add the following code:
| | var numberOfPaidContinues: Int { |
| | get { |
| | var qty: Int = 0 |
| | for product in GameData.shared.products { |
| | if product.id.contains("continue") { |
| | qty += product.quantity |
| | } |
| | } |
| | return qty |
| | } |
| | set(newValue) { |
| | let product = GameData.shared.products.filter( |
| | {$0.id.contains("continue")}).first |
| | product?.quantity = newValue ... |
Read now
Unlock full access