Guarding the ground with 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 very fast 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:

Guarding the ground with the Blade

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 ...

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.