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.
-
Reference to parent tileset.
Declaration
Swift
public weak var tileset: SKTileset! -
Unique id.
Declaration
Swift
public var uuid: String -
Local tile id.
Declaration
Swift
public var id: UInt32 -
Tiled type.
Declaration
Swift
public var type: String! -
Tile data name.
Declaration
Swift
public var name: String? { get } -
Tile texture.
Declaration
Swift
public var texture: SKTexture! -
Source image name (collections tileset)
Declaration
Swift
public var source: String! -
Source image size (collections tileset)
Declaration
Swift
public var sourceSize: CGSize? -
Probability value. This is parsed from the Tiled tileset data, though not used anywhere.
Declaration
Swift
public var probability: CGFloat -
Custom node properties.
Declaration
Swift
public var properties: [String : String] -
Ignore custom properties.
Declaration
Swift
public var ignoreProperties: Bool -
Getter for the size of this tile. (collections tile size may be different than that of the tileset).
Declaration
Swift
public var tileSize: CGSize { get } -
Tile offset.
Declaration
Swift
public var tileOffset: CGPoint -
Render scaling property.
Declaration
Swift
public var renderQuality: CGFloat
-
If animation is enabled, returns the current frames data.
Declaration
Swift
public var frames: [TileAnimationFrame] { get }Return Value
array of animation frames.
-
Indicates the tile is animated.
Declaration
Swift
public var isAnimated: Bool { get } -
Returns an aniamtion action for the tile data.
Declaration
Swift
public var animationAction: SKAction? { get }
-
Tile is walkable.
Declaration
Swift
public var walkable: Bool -
Tile represents an obstacle.
Declaration
Swift
public var obstacle: Bool -
Pathfinding weight.
Declaration
Swift
public var weight: CGFloat -
Global id for this tile.
Declaration
Swift
public var globalID: UInt32 { get }
-
Initialize an empty data structure.
Declaration
Swift
public init() -
Initialize the data with a tileset, id.
Declaration
Swift
public init(id: UInt32, withTileset tset: SKTileset)Parameters
idunique tile id.
tileSettileset reference.
-
Initialize the data with a tileset, id & texture.
Declaration
Swift
public init(id: UInt32, texture: SKTexture, tileSet: SKTileset)Parameters
idunique tile id.
texturetile texture.
tileSettileset reference.
-
Add tile animation to the data.
Declaration
Swift
public func addFrame(withID: UInt32, interval: Int, texture: SKTexture? = nil) -> TileAnimationFrameParameters
withIDid for frame.
intervalframe interval (in milliseconds).
tileTextureframe texture.
Return Value
animation frame container.
-
Returns an animation frame at the given index.
Declaration
Swift
public func frameAt(index: Int) -> TileAnimationFrame?Parameters
indexframe 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
newTexturenew 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
texturenew texture.
forFrameframe 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) -> BoolParameters
intervalframe interval (in milliseconds).
forFrameframe 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
indexframe 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
restorerestore the initial texture.
-
Returns a custom mirror for this object.
Declaration
Swift
public var customMirror: Mirror { get }
-
Parse the tile data’s properties value.
Declaration
Swift
public func parseProperties(completion: (() -> Void)?)Parameters
completionoptional completion closure.
-
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) -> TileAnimationFrameParameters
withIDid for frame.
intervalframe interval (in milliseconds).
tileTextureframe 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
idunique tile id.
texturetile texture.
tileSettileset 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
idunique tile id.
tileSettileset reference.
View on GitHub
Install in Dash
SKTilesetData Class Reference