SKTilesetData

public class SKTilesetData : CustomReflectable, TiledObjectType

The SKTilesetData structure stores data for a single tileset tile, referencing the tile texture or animation frames (for animated tiles).

This class optionally includes navigation properties for tile accessability, and graph node weight.

Properties

  • id: tile id (local).
  • type: tiled object type.
  • texture: Tile texture.
  • tileOffset: Tile offset.

Animation

Pathfinding Attributes

Initialization

Animation

  • Add tile animation to the data.

    Declaration

    Swift

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

    Parameters

    withID

    id for frame.

    interval

    frame interval (in milliseconds).

    tileTexture

    frame texture.

    Return Value

    animation frame container.

  • Returns an animation frame at the given index.

    Declaration

    Swift

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

    Parameters

    index

    frame index.

    Return Value

    animation frame container.

  • Force animated frames to update textures.

    Declaration

    Swift

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

    Declaration

    Swift

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

    Parameters

    newTexture

    new texture.

    Return Value

    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

    new texture.

    forFrame

    frame index.

    Return Value

    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

    frame interval (in milliseconds).

    forFrame

    frame index.

    Return Value

    frame duration was set correctly.

  • Remove a tile animation frame at a given index.

    Declaration

    Swift

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

    Parameters

    index

    frame index.

    Return Value

    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

    restore the initial texture.

Reflection

SKTilesetData

  • Parse the tile data’s properties value.

    Declaration

    Swift

    public func parseProperties(completion: (() -> Void)?)

    Parameters

    completion

    optional completion closure.

Deprecations

  • Local id for this tile data.

    Declaration

    Swift

    @available(*, deprecated, renamed: "id")
    public var localID: UInt32 { get }
  • Add tile an animation frame to the data.

    Declaration

    Swift

    @available(*, deprecated, renamed: "addFrame(withID:interval:texture:﹚")
    public func addFrame(withID: Int,
                         interval: Int,
                         tileTexture: SKTexture? = nil) -> TileAnimationFrame

    Parameters

    withID

    id for frame.

    interval

    frame interval (in milliseconds).

    tileTexture

    frame texture.

    Return Value

    animation frame container.

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

    Declaration

    Swift

    @available(*, deprecated, renamed: "init(id:texture:tileSet:﹚")
    public convenience init(id: Int, texture: SKTexture, tileSet: SKTileset)

    Parameters

    id

    unique tile id.

    texture

    tile texture.

    tileSet

    tileset reference.

  • Initialize the data with a tileset, id.

    Declaration

    Swift

    @available(*, deprecated, renamed: "init(id:withTileset:﹚")
    public convenience init(id: Int, withTileset tileSet: SKTileset)

    Parameters

    id

    unique tile id.

    tileSet

    tileset reference.