SKTilesetData

public class SKTilesetData : SKTiledObject
extension SKTilesetData: Hashable
extension SKTilesetData: CustomStringConvertible, CustomDebugStringConvertible

Overview

The SKTilesetData object stores data for a single tileset tile, referencing the tile texture, animation frames (for animated tiles) as well as tile orientation.

Also includes navigation properties for tile accessability, and graph node weight.

Properties

Property Description
id Tile id (local)
type Tiled type
texture Tile texture
tileOffset Tile offset

Tile Orientation

Pathfinding Attributes

Init

  • ▶︎init()

    Initialize an empty data structure.

    Declaration

    Swift

    public init()
  • Initialize the data with a tileset, id.

    Declaration

    Swift

    public init(id: Int, withTileset tileSet: SKTileset)

    Parameters

    tileId

    Int unique tile id.

    tileSet

    SKTileset tileset reference.

    Return Value

    SKTilesetData tile data.

  • Initialize the data with a tileset, id & texture.

    Declaration

    Swift

    public init(id: Int, texture: SKTexture, tileSet: SKTileset)

    Parameters

    id

    Int unique tile id.

    texture

    SKTexture tile texture.

    tileSet

    SKTileset tileset reference.

    Return Value

    SKTilesetData tile data.

Animation

  • Add tile animation to the data.

    Declaration

    Swift

    public func addFrame(withID: Int, interval: Int, tileTexture: SKTexture? = nil) -> TileAnimationFrame

    Parameters

    withID

    Int id for frame.

    interval

    Int frame interval (in milliseconds).

    tileTexture

    SKTexture? frame texture.

    Return Value

    TileAnimationFrame animation frame container.

  • Returns an animation frame at the given index.

    Declaration

    Swift

    public func frameAt(index: Int) -> TileAnimationFrame?

    Parameters

    index

    Int frame index.

    Return Value

    TileAnimationFrame? animation frame container.

  • Force the animated frames to update textuers.

    Declaration

    Swift

    public func forceAnimatedFramesUpdate()
  • Set the texture for the tile data.

    Declaration

    Swift

    public func setTexture(_ newTexture: SKTexture?) -> SKTexture?

    Parameters

    texture

    SKTexture? new texture.

    Return Value

    SKTexture? old texture (if it exists).

  • Set the texture for an animated frame at the given index.

    Declaration

    Swift

    public func setTexture(_ texture: SKTexture?, forFrame: Int) -> SKTexture?

    Parameters

    texture

    SKTexture? new texture.

    forFrame

    Int frame index.

    Return Value

    SKTexture? old texture (if it exists).

  • Set the duration for an animated frame at the given index.

    Declaration

    Swift

    public func setDuration(interval: Int, forFrame: Int) -> Bool

    Parameters

    interval

    Int frame interval (in milliseconds).

    forFrame

    Int frame index.

    Return Value

    Bool frame duration was set correctly.

  • Remove a tile animation frame at a given index.

    Declaration

    Swift

    public func removeFrame(at index: Int) -> TileAnimationFrame?

    Parameters

    at

    Int frame index.

    Return Value

    TileAnimationFrame? animation frame (if it exists).

  • Run tile animation.

    Declaration

    Swift

    public func runAnimation()
  • Remove tile animation. Animation is not actually destroyed, but rather blocked.

    Declaration

    Swift

    public func removeAnimation(restore: Bool = false)

    Parameters

    restore

    Bool restore the initial texture.

Generic Properties

Deprecated

  • ▶︎localID

    Local id for this tile data.

    Declaration

    Swift

    @available(*, deprecated, renamed: "id")
    public var localID: Int { get }