September 2018
Intermediate to advanced
434 pages
8h 47m
English
We have taken many steps to create our crate system. Now we can add our first crate: a crate in the GameScene class that will award health points to the player. Follow these steps to wire up the heart crate:
GameScene.swift, instantiate a new instance of the Crate class as a property of GameScene:let heartCrate = Crate()
GameScene didMove function, add the heartCrate to the node tree and call the function that makes it award a heart: // Spawn the heart crate, out of the way for now
self.addChild(heartCrate)
heartCrate.position = CGPoint(x: -2100, y: -2100)
heartCrate.turnToHeartCrate() GameScene.didSimulatePhysics function. Find the code that spawns the power-up star. We can ...Read now
Unlock full access