Classes

The following classes are available globally.

  • The Action class provides various animation types to be applied to nodes.

    Any action applied to a Node will also be applied to any of it’s child nodes.

    See more

    Declaration

    Swift

    public final class Action
  • A SpriteNode is a node that can be rendered with a Texture. The applied texture can also be blended with a color.

    See more

    Declaration

    Swift

    public class SpriteNode: Node, Renderable
  • A ShapeNode is a node for creating colored shapes. Currently only supports rectangular shapes.

    See more

    Declaration

    Swift

    public class ShapeNode: Node, Renderable
  • A Texture holds an image, essentially, to be applied to a SpriteNode.

    Currently these are being loaded synchronously using MTKTextureLoader.

    Seealso

    TextureAtlas
    See more

    Declaration

    Swift

    public class Texture
  • The GameViewController is responsible for mainly the game/rendering loop.

    A basic setup in viewDidLoad() would look something like

    super.viewDidLoad()
    
    let view = self.view as! GameView
    scene = Scene(size: view.bounds.size)
    view.presentScene(scene)
    
    See more

    Declaration

    Swift

    public class GameViewController: UIViewController
  • A collection of Math related helper functions.

    See more

    Declaration

    Swift

    public final class Math
  • A Scene is a node object that holds everything on screen as the root of the node tree. Anything that needs to be displayed must be added to either the scene directly or a node that is already part of the scene’s tree.

    The scene is also responsible for setting up and maintaining the render loop.

    In general, this is where all the stuff should happen. Any game using this engine should subclass this and override the update(_:) method.

    • discussion: Unlike other Node types it’s safe to force unwrap the Camera object on a scene. It will always have a default value and unless no other cameras are created it will be the same camera used for each node added to the scene. Also, it probably makes little sense to add a scene as a child to another scene and may cause problems.
    See more

    Declaration

    Swift

    public class Scene: Node
  • A TextureAtlas is an object that contains multiple textures to be loaded and used as one texture.

    Since this engine is tile based I wrote a rather inefficient texture packing script to be insert into the build phase. It creates two new xcassets from an existing one that packs all the sprites together and creates the JSON data.

    Seealso

    ${PROJECT_DIR}/resources/README.md and AtlasGen.py in the same directory.
    See more

    Declaration

    Swift

    public class TextureAtlas
  • A TextNode creates a string sprite essentially.

    This still needs to be updated for modifying the text properties such as alignment. As well as support for glowing/outlined/better anti-aliased stuff, probably.

    Note

    It also currently does not support being updated even if the text property is. I’m not sure if that will ever change or if I’ll make the text property private at some point.

    Warning

    This will be incredibly slow in debug mode. I’m still trying to figure out a work around. Generally, creating the FontAtlas using Fonts in release mode will speed up the process significantly. After which switching back to debug will be ok as it’ll be cached.

    Seealso

    FontAtlas and Fonts classes.

    See more

    Declaration

    Swift

    public class TextNode: Node, Renderable
  • A GameView is a subclass of MTKView in order to tie into some of logic/delegate stuff provided for free by Apple.

    See more

    Declaration

    Swift

    public class GameView: MTKView
  • A Node is the most basic object from which most game type objects should be subclassed from.

    This type cannot be rendered but contains all the necessary geometry to be used as if it were being displayed. It also contains the relevant information for adding and removing nodes to the tree hierarchy, running actions, and updating.

    The following classes are subclasses of this and in general should be sufficient for most purposes. - Scene - ShapeNode - SpriteNode - TextNode - Camera

    See more

    Declaration

    Swift

    public class Node: NodeGeometry, Tree, Equatable, Hashable