Capítulo 398 de 859

Chapter 398: ConditionalNode

Core Idea

Represents a logical if/else statement. Can be used as an alternative to the If()/Else() syntax.

The select() method is called in a chaining fashion on a condition. The parameter nodes of select() determine the outcome of the entire statement.

Key Concepts

  • condNode : Node: The node that defines the condition.
  • elseNode : Node: The node that is evaluate when the condition ends up false.
  • ifNode : Node: The node that is evaluate when the condition ends up true.

Code Examples

velocity = position.greaterThanEqual( limit ).select( velocity.negate(), velocity );
  • What it demonstrates: Typical usage of ConditionalNode.

Reference Tables

Constructor

Signature
new ConditionalNode( condNode : Node, ifNode : Node, elseNode : Node )

Properties

PropertyDescription
.condNode : NodeThe node that defines the condition.
.elseNode : NodeThe node that is evaluate when the condition ends up false.
.ifNode : NodeThe node that is evaluate when the condition ends up true.

Methods

MethodDescription
.generateNodeType( builder : NodeBuilder ) : stringThis method is overwritten since the node type is inferred from the if/else nodes.

Key Takeaways

  1. ConditionalNode extends: EventDispatcher → Node
  2. Most relevant properties: condNode, elseNode, ifNode.
  3. Key methods: generateNodeType.

Connects To