Instance Method

insertChild(_:at:)

Inserts a child into a specific position in the receiver’s list of child nodes.

Declaration

func insertChild(_ node: SKNode, at index: Int)

Parameters

node

The node to add. The node must not already have a parent.

index

The position in the array to insert the node.

See Also

Working with Node Trees

func addChild(SKNode)

Adds a node to the end of the receiver’s list of child nodes.

func isEqual(to: SKNode)

Compares the parameter node to the receiving node.

func move(toParent: SKNode)

Moves the node to a new parent node in the scene.

func removeFromParent()

Removes the receiving node from its parent.

func removeAllChildren()

Removes all of the node’s children.

func removeChildren(in: [SKNode])

Removes a list of children from the receiving node.

func inParentHierarchy(SKNode)

Returns a Boolean value that indicates whether the node is a descendant of the target node.

var children: [SKNode]

The node’s children.

var parent: SKNode?

The node’s parent node.

var scene: SKScene?

The scene node that contains the node.