A new enemy - the Mad Fly

Pierre Penguin will need to dodge more than just Bees to accomplish his goal. We will add a few new enemies in this chapter, starting with the MadFly class. The Mad Fly is quite grumpy, as you can see:

A new enemy - the Mad Fly

Adding the MadFly class

MadFly is another straightforward class; it looks a lot like the bee code. Create a new Swift file named MadFly.swift and enter this code:

import SpriteKit class MadFly: SKSpriteNode, GameSprite { var initialSize = CGSize(width: 61, height: 29) var textureAtlas: SKTextureAtlas = SKTextureAtlas(named: "Enemies") var flyAnimation = SKAction() init() { super.init(texture: nil, color: .clear, size: initialSize) ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.