SKTiledGraphNode
public class SKTiledGraphNode : GKGridGraphNode, TiledObjectType
The SKTiledGraphNode node is a custom GKGridGraphNode object that adds a weight parameter for
use with Tiled scene properties. Can be used with normal GKGridGraphNode
instances. The SKTiledGraphNode.weight property is used to affect the estimated cost to a
connected node. (Increasing the weight makes it less likely to be travelled to, decreasing more likely).
Usage
// query a node in the graph and increase the weight property
if let node = graph.node(atGridPosition: coord) as? SKTiledGraphNode {
node.weight = 25.0
}
-
Unique id.
Declaration
Swift
public var uuid: String -
Node type.
Declaration
Swift
public var type: String! -
Node attributes.
Declaration
Swift
public var properties: [String : String] -
Ignore custom node properties.
Declaration
Swift
public var ignoreProperties: Bool -
Render scaling property.
Declaration
Swift
public var renderQuality: CGFloat -
Weight property.
Declaration
Swift
public var weight: Float
-
Initialize the node with a weight parameter.
Declaration
Swift
public init(gridPosition: simd_int2, weight: Float = 1.0)Parameters
gridPositionvector simd_int2 coordinates.
weightnode weight.
-
Instantiate the node with a decoder instance.
Declaration
Swift
required public init?(coder aDecoder: NSCoder)Parameters
aDecoderdecoder.
-
The
GKGridGraphNode.costmethod is used in theGKGridGraphNode.findPathToNodemethod. Returns the cost (lower is better) for each node in the possible nodes.Declaration
Swift
public override func cost(to node: GKGraphNode) -> FloatParameters
nodenode to estimate from.
Return Value
cost to travel to the given node.
-
Returns the heuristic cost to node.
Declaration
Swift
public override func estimatedCost(to node: GKGraphNode) -> FloatParameters
nodetarget graph node.
Return Value
heuristic cost to node.
-
Parse the tile data’s properties value.
Declaration
Swift
public func parseProperties(completion: (() -> Void)?)Parameters
completionoptional completion function.
View on GitHub
Install in Dash
SKTiledGraphNode Class Reference