SKTiledObject
@objc
public protocol SKTiledObject
Overview
The SKTiledObject protocol defines a basic data structure for mapping custom Tiled
properties to SpriteKit objects. Objects conforming to this protocol will
automatically receive properties from the Tiled scene, unless supressed
by setting the object’s SKTiledObject.ignoreProperties property.
Properties
| Property | Description |
|---|---|
| uuid | Unique object id. |
| type | Tiled object type. |
| properties | Object of custom Tiled properties. |
| ignoreProperties | Ignore Tiled properties. |
| renderQuality | Resolution multiplier value. |
Instance Methods
| Method | Description |
|---|---|
| parseProperties | Parse function (with optional completion block). |
Usage
// query a Tiled string property
if let name = tiledObject.stringForKey("name") {
tiledObject.name = name
}
// query a boolean property
let isDynamic = tiledObject.boolForKey("isDynamic") == true
-
▶︎uuidUnique object id (layer & object names may not be unique).
Declaration
Swift
var uuid: String { get set } -
▶︎typeObject type.
Declaration
Swift
var type: String! { get set } -
Storage for custom Tiled properties.
Declaration
Swift
var properties: [String : String] { get set } -
Ignore custom properties.
Declaration
Swift
var ignoreProperties: Bool { get set } -
Parse function (with optional completion block).
Declaration
Swift
func parseProperties(completion: (() -> Void)?) -
Render scaling property.
Declaration
Swift
var renderQuality: CGFloat { get } -
▶︎hash(into:Extension method) Hash id.
Declaration
Swift
public func hash(into hasher: inout Hasher)
-
▶︎subscript(_:Extension method) Return a string value for the given key, if it exists.
Usage
if let name = tileData["name"] { print("tile data is named \"\(name)\"") }Declaration
Swift
public subscript(key: String) -> String? { get }Parameters
keyStringkey to query.Return Value
String?value for the given key. -
▶︎hasPropertiesExtension methodReturns true if the node has stored properties.
Declaration
Swift
public var hasProperties: Bool { get }Return Value
Boolproperties are not empty. -
▶︎hasKey(_:Extension method) Returns true if the node has the given SKTiled property (case insensitive).
Declaration
Swift
public func hasKey(_ key: String) -> BoolParameters
keyStringkey to query.Return Value
Boolproperties has a value for the key. -
▶︎boolForKey(_:Extension method) Returns a boolean value for the given key.
Declaration
Swift
public func boolForKey(_ key: String) -> BoolParameters
keyStringproperties key.Return Value
Boolvalue for properties key. -
▶︎stringForKey(_:Extension method) Returns a string for the given SKTiled key.
Declaration
Swift
public func stringForKey(_ key: String) -> String?Parameters
keyStringproperties key.Return Value
Stringvalue for properties key. -
▶︎intForKey(_:Extension method) Returns a integer value for the given key.
Declaration
Swift
public func intForKey(_ key: String) -> Int?Parameters
keyStringproperties key.Return Value
Int?value for properties key. -
▶︎doubleForKey(_:Extension method) Returns a float value for the given key.
Declaration
Swift
public func doubleForKey(_ key: String) -> Double?Parameters
keyStringproperties key.Return Value
Double?value for properties key. -
▶︎setValue(forKey:Extension method_: ) Sets a named SKTiled property. Returns the value, or nil if it does not exist.
Declaration
Swift
public func setValue(forKey key: String, _ value: String)Parameters
keyStringproperty key.valueStringproperty value. -
▶︎removeProperty(forKey:Extension method) Remove a named SKTiled property, returns the value as a string (if property exists).
Declaration
Swift
public func removeProperty(forKey key: String) -> String?Parameters
keyStringproperty key.Return Value
String?property value (if it exists). -
▶︎propertiesStringExtension methodReturns a string representation of the node’s properties.
Declaration
Swift
public var propertiesString: String { get }
View on GitHub
SKTiledObject Protocol Reference