Classes
The following classes are available globally.
-
A
See moreShapeNode
is a node for creating colored shapes. Currently only supports rectangular shapes.Declaration
Swift
public class ShapeNode: Node, Renderable
-
A
Texture
holds an image, essentially, to be applied to aSpriteNode
.Currently these are being loaded synchronously using
MTKTextureLoader
.Seealso
TextureAtlas
Declaration
Swift
public class Texture
-
The
GameViewController
is responsible for mainly the game/rendering loop.A basic setup in viewDidLoad() would look something like
See moresuper.viewDidLoad() let view = self.view as! GameView scene = Scene(size: view.bounds.size) view.presentScene(scene)
Declaration
Swift
public class GameViewController: UIViewController
-
A collection of Math related helper functions.
See moreDeclaration
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 theCamera
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.
Declaration
Swift
public class Scene: Node
- discussion: Unlike other
-
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 andAtlasGen.py
in the same directory.Declaration
Swift
public class TextureAtlas
-
A
TextNode
creates astring
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
usingFonts
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
andFonts
classes.Declaration
Swift
public class TextNode: Node, Renderable
-
A
See moreGameView
is a subclass of MTKView in order to tie into some of logic/delegate stuff provided for free by Apple.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 moreDeclaration
Swift
public class Node: NodeGeometry, Tree, Equatable, Hashable