Protocols

The following protocols are available globally.

  • The NodeGeometry protocol is used to give an object enough information to be placed in a scene and possibly rendered.

    Note

    Any rendered Node must have the camera property be non-nil. I’m still trying to figure out a nicer way to enforce this.

  • discussion: Conforming to this protocol will grant access to most of the underlying maths required to render an object properly. Additionally, conforming to Tree will grant access to adding custom nodes to a Scene graph. Renderable has all the required information to do both of the above, as well as draw a node using a custom Pipeline.

  • Seealso

    Renderable and Tree.

    See more

    Declaration

    Swift

    public protocol NodeGeometry: class
  • Any type that needs to be updated during the main game loop should implement the Updateable protocol.

    See more

    Declaration

    Swift

    public protocol Updateable: class, Tree
  • The Tree protocol is used by any object that wishes to be part of the tree hiearchy with the root more than likely being a Scene.

    The basic implementation of this is in the Node class where the hiearchy is more or less a group of sets so that a Node cannot be added multiple times. It would still be possible to add a node to another parent but I’m not sure what will happen or if that even makes sense. Probably best to avoid doing stuff like that.

    See more

    Declaration

    Swift

    public protocol Tree: class
  • The Renderable protocol is required by an object that wishes to be rendered. Applying this protocol to an object should be sufficient for creating a custom pipeline.

    The following base classes conform to this protocol: - ShapeNode - SpriteNode - TextNode

  • discussion: Currently, this doesn’t need to be public as there’s no way to add a custom Pipeline to the Renderer at some point I will expose that. I’m just not entirely sure how I want to do it yet.

  • Seealso

    NodeGeometry and Tree

    See more

    Declaration

    Swift

    public protocol Renderable: NodeGeometry, Tree