SKTiledGraphNode
public class SKTiledGraphNode : GKGridGraphNode, SKTiledObject
Overview
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
}
-
▶︎uuidUnique id.
Declaration
Swift
public var uuid: String -
▶︎typeDeclaration
Swift
public var type: String! -
Declaration
Swift
public var properties: [String : String] -
Declaration
Swift
public var ignoreProperties: Bool -
Declaration
Swift
public var renderQuality: CGFloat -
▶︎weightWeight property.
Declaration
Swift
public var weight: Float
-
Initialize the node with a weight parameter.
Declaration
Swift
public init(gridPosition: int2, weight: Float = 1.0)Parameters
gridPositionint2vector int2 coordinates.weightFloatnode weight.Return Value
SKTiledGraphNodenode instance.
-
The
GKGridGraphNode.costmethod is used in theGKGridGraphNode.findPathToNodemethod. Returns the cost (lower is better) for each node in the possible nodes.Declaration
Swift
override public func cost(to node: GKGraphNode) -> FloatParameters
nodeGKGraphNodenode to estimate from.Return Value
Floatcost to travel to the given node. -
Returns the heuristic cost to node.
Declaration
Swift
override public func estimatedCost(to node: GKGraphNode) -> FloatParameters
nodeGKGraphNodetarget graph node.Return Value
Floatheuristic cost to node. -
Parse the tile data’s properties value.
Declaration
Swift
public func parseProperties(completion: (() -> Void)?)Parameters
completion() -> Void)?optional completion function.
View on GitHub
SKTiledGraphNode Class Reference