Adding crates to smash open
Many classic games feature breakable crates. There is something very satisfying about flying into a crate and smashing it open. We will now add breakable crates to our game. Some of these crates will reward the player with coins, and some will reward the player with a health refill. Follow these steps to create the basic crate system:
Add the art assets to your project. Open
Assets.xcassets
, open the Environment Sprite Atlas, and drag the contents of theCrates
folder from the downloadable asset bundle. When you are done, you should seecrate
andcrate-power-up
appear in your Environment Atlas, as shown in the following screenshot:Open
GameScene.swift
and add a new physics category to thePhysicsCategory enum
. We will create a physics category for crates with the value 64. When you are done, yourPhysicsCategory enum
should look like this:enum PhysicsCategory: UInt32 { case penguin = 1 case damagedPenguin = 2 case...