TileSet

public class TileSet : Loadable, MutablePropertied

A TileSet represents a Tiled tile set, most typically loaded as part of loading a Map.

  • The name of the TileSet

    Declaration

    Swift

    public let name: String
  • The size in pixels of a Tile. Note that individual Tiles may differ in size but this size will be used as an assumption

    Declaration

    Swift

    public let tileSize: PixelSize
  • The user specified Properties of the TileSet

    Declaration

    Swift

    public var properties: Properties
  • The number of tiles in the TileSet

    Declaration

    Swift

    public var count: Int { get }
  • Creates a new instance of the a TileSet

    Declaration

    Swift

    public init(name: String, tileSize: PixelSize, properties: Properties)

    Parameters

    name

    The name of the TileSet

    tileSize

    The size of the Tiles in the TileSet

    properties

    Any user specified Properties

  • Returns the local id of the tile (outside of the context of a map) of a given tile

    Declaration

    Swift

    public func localId(of tile: Tile) -> UInt32?

    Parameters

    tile

    The tile

    Return Value

    nil if the Tile is

  • Retreives the Tile specified by the index from the TileSet

    Declaration

    Swift

    public subscript(tileId: UInt32) -> Tile? { get set }

    Parameters

    tileId

    The index of the Tile starting at 0

    Return Value

    The Tile or nil if no Tile with the specified id exists

  • Creates and returns an instance of TileSetLoader which will load tilesets from Tiled tsx files

    Declaration

    Swift

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

    Parameters

    project

    The project the TileSet will be loaded connected to

    Return Value

    An instance of TileSetLoader

  • Maps should be cached, as they are value types a new instance is created anyway so there will not be unintended side effects

    Declaration

    Swift

    public let cache: Bool
  • A TileSet should be the same across all Maps in a project so no deep copy is done

    Declaration

    Swift

    public func newInstance() -> Self

    Return Value

    self