Protocol

HasHierarchy

An interface that provides access to a parent entity and child entities.

Declaration

protocol HasHierarchy : Entity

Overview

All entities automatically adopt this protocol because the Entity base class does. This adoption gives all entities a collection of methods for managing the hierarchy.

Topics

Managing the Parent

var parent: Entity?

The parent entity.

func setParent(Entity?, preservingWorldTransform: Bool)

Attaches the entity as a child to the specified entity.

func removeFromParent(preservingWorldTransform: Bool)

Removes the entity from its current parent or from the scene if it is a root entity.

Managing Children

var children: Entity.ChildCollection

The child entities that the entity manages.

func addChild(Entity, preservingWorldTransform: Bool)

Adds the given entity to the collection of child entities.

func removeChild(Entity, preservingWorldTransform: Bool)

Removes the given child from the entity.

struct Entity.ChildCollection

A collection of child entities.

Relationships

Conforming Types

See Also

Establishing a Hierarchy

var parent: Entity?

The parent entity.

func setParent(Entity?, preservingWorldTransform: Bool)

Attaches the entity as a child to the specified entity.

func removeFromParent(preservingWorldTransform: Bool)

Removes the entity from its current parent or from the scene if it is a root entity.

var children: Entity.ChildCollection

The child entities that the entity manages.

func addChild(Entity, preservingWorldTransform: Bool)

Adds the given entity to the collection of child entities.

func removeChild(Entity, preservingWorldTransform: Bool)

Removes the given child from the entity.

struct Entity.ChildCollection

A collection of child entities.