PHASERandomNodeDefinition
A sound event node that invokes one of its child nodes at random.
Declaration
class PHASERandomNodeDefinitionOverview
When the framework invokes a random node, it passes the invocation on to one of its children at random. The weight you choose for a child node in the addSubtree(_:weight:) argument skews the node’s selection chances.
Choose from Alternate Sounds
This class can model real-world cases where an event varies slightly, such as when footsteps sound slightly different because of the unique ground composition at each step.
[Image]
The following code creates an instance of this class that selects from three different footstep sounds. The weights determine that an uncommon footstep noise plays half as frequently as the common footstep. And a third footstep noise plays 10% of the time.