Guarding the ground - adding the Blade
The Blade
class will keep Pierre from flying too low. This enemy class will be similar to the others we have created, with one exception: we will generate a physics body based on the texture. The physics body circles that we have been using are much faster computationally and are usually sufficient to describe the shapes of our enemies; the Blade
class requires a more complicated physics body, given its half-circle shape and bumpy edges:
Adding the Blade class
To add the Blade
class, create a new file named Blade.swift
and add the following code:
import SpriteKit class Blade: SKSpriteNode, GameSprite { var initialSize = CGSize(width: 185, height: 92) var textureAtlas:SKTextureAtlas = SKTextureAtlas(named: "Enemies") var spinAnimation = SKAction() init() { super.init(texture: nil, color: .clear, size: initialSize) let startTexture =...