Contents

PHASESwitchNodeDefinition

A node that passes invocation to only one of its child nodes.

Declaration

class PHASESwitchNodeDefinition

Overview

A switch node takes a different path in a sound-event hierarchy depending on the value that the app supplies for the node’s switch metaparameter. You define the available paths ahead of time by calling addSubtree(_:switchValue:) at least twice and supplying the subtree’s unique string name as the switch value. When your app invokes a sound event at runtime, PHASE checks the value of switchMetaParameterDefinition to determine which path to take.

[Image]

Switch Between Mulitple Node Trees

For example, the following diagram represents a node tree that plays one of three grass or sidewalk footstep sounds, depending on the app’s current state. The app sets a value for the switch-node metaparameter according to the terrain on which the player in a game currently stands.

[Image]

The following code creates a random node subtree for each terrain type and adds each one as a subtree to the switch node.

Topics

Creating a Node

Managing Child Nodes

See Also

Control Nodes