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 |
-
▶︎uuid
Unique id.
Declaration
Swift
public var uuid: String
-
▶︎id
Tile id (local).
Declaration
Swift
public var id: Int
-
▶︎type
Tiled type.
Declaration
Swift
public var type: String!
-
▶︎name
Tile data name.
Declaration
Swift
public var name: String? { get }
-
▶︎texture
Tile texture.
Declaration
Swift
public var texture: SKTexture!
-
▶︎source
Source image name (collections tileset)
Declaration
Swift
public var source: String!
-
Tile occurance probability (parsed from Tiled, not currently used).
Declaration
Swift
public var probability: CGFloat
-
Custom Tiled properties.
Declaration
Swift
public var properties: [String : String]
-
Node ignores custom properties.
Declaration
Swift
public var ignoreProperties: Bool
-
Tile offset.
Declaration
Swift
public var tileOffset: CGPoint
-
Render scaling property.
Declaration
Swift
public var renderQuality: CGFloat
-
▶︎frames
Tile animation frame storate.
Declaration
Swift
public var frames: [TileAnimationFrame] { get }
-
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 }
-
▶︎walkable
Tile is walkable.
Declaration
Swift
public var walkable: Bool
-
▶︎obstacle
Tile represents an obstacle.
Declaration
Swift
public var obstacle: Bool
-
▶︎weight
Pathfinding weight.
Declaration
Swift
public var weight: CGFloat
-
Collision objects (not yet implemented).
Declaration
Swift
public var collisions: [SKTileObject]
-
▶︎globalID
Global id for this tile.
Declaration
Swift
public var globalID: Int { get }
-
▶︎init()
Initialize an empty data structure.
Declaration
Swift
public init()
-
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.
-
Parse the tile data’s properties value.
Declaration
Swift
public func parseProperties(completion: (() -> Void)?)
-
▶︎localID
Local id for this tile data.
Declaration
Swift
@available(*, deprecated, renamed: "id") public var localID: Int { get }