-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Swift Game Development
By :

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 the Crates
folder from the downloadable asset bundle. When you are done, you should see crate
and crate-power-up
appear in your Environment Atlas, as shown in the following screenshot:
Open GameScene.swift
and add a new physics category to the PhysicsCategory enum
. We will create a physics category for crates with the value 64. When you are done, your PhysicsCategory enum
should look like this:
enum PhysicsCategory: UInt32 { case penguin = 1 case damagedPenguin = 2 case...