Map

public struct Map : LayerContainer, Loadable, MutablePropertied

Represents a Tiled map which can be loaded from a Tiled tmx file (other Tiled formats can be supported in the future, such as JSON). It contains the root collection of Layers as well as carrying the references to the TileSets used by the Map

  • The size of the map in tiles

    Declaration

    Swift

    public let mapSize: TileGridSize
  • The size of a tile in pixels

    Declaration

    Swift

    public let tileSize: PixelSize
  • Properties of the map

    Declaration

    Swift

    public var properties: Properties
  • The size of the map in pixels

    Declaration

    Swift

    public var pixelSize: PixelSize { get }
  • The orientation of the map

    Declaration

    Swift

    public var orientation: Orientation
  • The rendering order the map was designed in

    Declaration

    Swift

    public var renderingOrder: RenderingOrder
  • The color that should be used to render the background of the map

    Declaration

    Swift

    public var backgroundColor: Color?
  • The various layers in the map

    Declaration

    Swift

    public var layers: [Layer]
  • The tilesets the map uses

    Declaration

    Swift

    public var tileSets: [TileSet] { get }
  • Creates a new instance of a map

    Declaration

    Swift

    public init(with mapSize: TileGridSize, and tileSize: PixelSize, orientation: Orientation, renderingOrder: RenderingOrder)

    Parameters

    mapSize

    The size of the map in tiles

    tileSize

    The size of tiles in the map (pixel dimensions)

    orientation

    The Orientation of the map

    renderingOrder

    The RenderingOrder of the map

  • Retreive a tile based on its TileGID

    Declaration

    Swift

    public subscript(tile: TileGID) -> Tile? { get }
  • Creates and returns an instance of MapLoader which will load maps from Tiled tmx files

    Declaration

    Swift

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

    Parameters

    project

    The project the Map will be loaded into

    Return Value

    An instance of MapLoader

  • 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
  • Returns self as it is a value type

    Declaration

    Swift

    public func newInstance() -> Map

    Return Value

    This value