SKTilemapDelegate
public protocol SKTilemapDelegate : AnyObject
Overview
Methods that allow interaction with an SKTilemap object as it is being created to customize its properties.
Properties
| Property | Description |
|---|---|
| zDeltaForLayers | Default z-distance between layers. |
Instance Methods
Delegate callbacks are called asynchronously as the map is being read from disk and rendered:
| Method | Description |
|---|---|
| didBeginParsing | Called when the tilemap is instantiated. |
| didAddTileset | Called when a tileset is added to a map. |
| didAddLayer | Called when a layer is added to a tilemap. |
| didReadMap | Called when the tilemap is finished parsing. |
| didRenderMap | Called when the tilemap layers are finished rendering. |
| didAddNavigationGraph | Called when the a navigation graph is built for a layer. |
| objectForTileType | Specify a custom tile object for use in tile layers. |
| objectForVectorType | Specify a custom object for use in object groups. |
| objectForGraphType | Specify a custom graph node object for use in navigation graphs. |
Custom Objects
Custom object methods can be used to substitute your own objects for tiles:
func objectForTileType(named: String? = nil) -> SKTile.Type {
if (named == "MyTile") {
return MyTile.self
}
return SKTile.self
}
-
▶︎zDeltaForLayersExtension methodDetermines the z-zposition difference between layers.
Declaration
Swift
public var zDeltaForLayers: CGFloat { get } -
▶︎didBeginParsing(_:Extension method) -
▶︎didAddTileset(_:Extension method) -
▶︎didAddLayer(_:Extension method) Called when a layer is added to a tilemap.
Declaration
Swift
public func didAddLayer(_ layer: SKTiledLayerObject)Parameters
layerSKTiledLayerObjecttilemap instance. -
▶︎didReadMap(_:Extension method) -
▶︎didRenderMap(_:Extension method) -
▶︎didAddNavigationGraph(_:Extension method) Called when the a navigation graph is built for a layer.
Declaration
Swift
public func didAddNavigationGraph(_ graph: GKGridGraph<GKGridGraphNode>)Parameters
graphGKGridGraph<GKGridGraphNode>graph instance. -
▶︎objectForTileType(named:Extension method) Specify a custom tile object for use in tile layers.
Declaration
Swift
public func objectForTileType(named: String? = nil) -> SKTile.TypeParameters
classNameStringoptional class name. -
▶︎objectForVectorType(named:Extension method) Specify a custom object for use in object groups.
Declaration
Swift
public func objectForVectorType(named: String? = nil) -> SKTileObject.TypeParameters
namedStringoptional class name. -
▶︎objectForGraphType(named:Extension method) Specify a custom graph node object for use in navigation graphs.
Declaration
Swift
public func objectForGraphType(named: String?) -> GKGridGraphNode.TypeParameters
namedStringoptional class name.
View on GitHub
SKTilemapDelegate Protocol Reference