Another terror - Bats!
We are getting into quite a rhythm with creating new classes. Now, we will add a Bat to swarm with the Bees. The Bat is small, but has a very sharp fang:
Adding the Bat class
To add the Bat
class, create a file named Bat.swift
and add this code:
import SpriteKit class Bat: SKSpriteNode, GameSprite { var initialSize = CGSize(width: 44, height: 24) var textureAtlas:SKTextureAtlas = SKTextureAtlas(named: "Enemies") var flyAnimation = SKAction() init() { super.init(texture: nil, color: .clear, size: initialSize) self.physicsBody = SKPhysicsBody(circleOfRadius: size.width / 2) self.physicsBody?.affectedByGravity = false createAnimations() self.run(flyAnimation) } func createAnimations() { let flyFrames:[SKTexture] = [ textureAtlas.textureNamed...