April 2021
Beginner to intermediate
506 pages
11h 57m
English
What good would a shop be if the player couldn’t access it?
Switch to the GameScene.swift file and add the following new properties (be sure to add them below the line that reads var isContinue: Bool = false):
| | // Reference Scene |
| | let shopButton = SKSpriteNode(imageNamed: "shop") |
| | var shopScene: ShopScene! |
| | var shopIsOpen = false |
You’ll use these properties to show and hide the shop scene.
Jump to the end of the file, and inside the GameScene extension, below the useContinue() method, add the following code:
| | func setupShop() { |
| | // Set up Shop Button |
| | shopButton.name = "shop" |
| | shopButton.zPosition = Layer.shop.rawValue |
| | shopButton.position = CGPoint(x: frame.minX + 75, ... |
Read now
Unlock full access