Loadable

public protocol Loadable

Implemented by any type that wants to be loaded (and cached, and instanced) through the TiledKit Project system. This makes it very easy to extend to a specific game engine.

  • Construct and return a ResourceLoader suitable for the protocol implementer

    Declaration

    Swift

    static func loader(for project: Project) -> ResourceLoader

    Parameters

    project

    The Project the ResourceLoader should work through to get any additional resources

  • Instances should return false if they should not be cached (perhaps they are very large, temporary, or change over time)

    Declaration

    Swift

    var cache: Bool { get }
  • When the Loadable has been cached this method will be called and if the object should create a copy of itself it can do it here. This is especially important for types that are classes as unless the instance is exactly the same (such as an image) and will not have been changed by previous instances, a copy should have been created. If it is acceptable that every instance of the Loadable is exactly the same object, the function can return self.

    Declaration

    Swift

    func newInstance() -> Self