Adding custom sprite

Next, let's add our custom sprite to the scene. We will use the same asset that we used to make the regular SpriteKit game. One difference is that this time we will use the bee as one of the enemies. So, add the bat-fly, bat, bee-fly, bee, madfly-fly, and madfly assets to the assets in the Enemies folder:

Adding custom sprite

Also, add the GameSprite.swift, Bee.swift, Bat.swift, and Madfly.swift files and make changes to them as explained in this section.

Here is the GameSprite.swift file:

import SpriteKit

protocol GameSprite {
    var textureAtlas: SKTextureAtlas { get set }
    var initialSize: CGSize { get set }
}

Here is the modified Bee.swift file:

import ...

Get Swift Game Development - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.