Skip to main content

Examples Using Predefined Behaviors

Contents List

Thermometer Example

1. Drag&drop a Slider Control and a Text Value Control from the Controls Panel of the Toolbox to the Scene Editor or the Scene Tree.

drawing-7-1677217038.png

2. Set the Slider's Minimum to "-50,00" and the maximum to "+50,00".

drawing-7-1677217059.png

3. Change the Text Value Control's "Format Text" Property to "%d °C".

drawing-7-1677217081.png

4. Drag&drop a Forward Value Behavior (which is a Value Processing Behavior) from the Behaviors Panel of the Toolbox onto the Slider in the Scene Tree.

drawing-7-1677217098.png

This is what the Scene Tree should look like now:

drawing-7-1677217109.png

5. Select the Forward Value Behavior in the right side of the Scene Tree view. Set the Forward Value Behavior's Target Node to the Text Value Control you have added to the scene in step 1 by clicking on the magnifying glass on the right of the input field and selecting the Text Value Control in the "Choose Item" dialog.

drawing-7-1677217134.png

After that, the Forward Value Behavior's Properties will look as follows.

drawing-7-1677217146.png

6. Drag&drop a Value Behavior (which is a Value Processing Behavior) from the Behaviors Panel of the Toolbox onto the Text Value Control in the Scene Tree.

drawing-7-1677217166.png

7. Select the Value Behavior on the right side of the Scene Tree View. Set the Value Behavior's AcceptValueEvent Property to "true" by checking the checkbox.

drawing-7-1677217184.png

8. Select the "Text Value" Control in the Scene Tree Panel and drag&drop two Action on Value Behaviors (which are Value Processing Behaviors) from the Behaviors Panel of the Toolbox onto the "Receivers" of the "Value Behavior" in right side of the SceneTree Panel.

drawing-7-1677217211.png

9. Add a condition to the Action on Value Behaviors you have just added by dragging&dropping a Check processed Value Behavior (which is a Condition - Control Behavior) onto each of the Action on Value Behaviors you have just added.

drawing-7-1677217229.png

10. Configure one of the Conditions to "LowerThan 0,00" and the other one to "GreaterThan 0,00".

drawing-7-1677217255.png

11. Drag&drop a Set Color SetColor Action (which is a Action - Property Behavior) from the Toolbox view onto the Actions of each of the Action on Value Behaviors in the SceneTree.

drawing-7-1677217282.png

12. Set the color to Blue on the Action on Value Behavior with the Condition Lower Than 0,00 and set the Color to Red on the Action on Value Behavior with the Condition Greater Than 0,00.

drawing-7-1677217306.png

13. Save your solution and start the Player through the Play button (with the option "Generate and Play") in the Toolbar on the top to see the result.

drawing-7-1677217319.png

14. The text color of the Text Value Control displaying the temperature in degrees celcius will turn blue once the value of the slider gets lower than zero and it will turn red once the value becomes greater than zero.

drawing-7-1677217397.png

Back to the menu


Align Pivot Example

1. Drag&drop a Group from the "Nodes 2D" Panel of the Toolbox to the SceneEditor or the Scene Tree. Choose the follwing two Images from the Construction Kit (in the Solution Explorer) and drag&drop them onto the Group node in the SceneTree: GaugeBmP and GaugeNeedleBmp

drawing-7-1677217510.png

2. Arrange the Controls in the SceneEditor so that "GaugeNeedleBmp" is the last entry of the Group Node in the Scene Tree.

drawing-7-1677217525.png

3. Select the "Pivot only" Translation tool in the toolbar and move the pivot of "GaugeBmP" to the center of the image and the pivot of "GaugeNeedleBmp" to the usual center of rotation of a gauge needle.

drawing-7-1677217601.png

4. Drag&drop the Align Pivot Behavior (which is a Control Behavior) from the Toolbox view onto the Group node in the SceneTree.

drawing-7-1677217632.png

5. The Align Pivot Behavior does not have any properties to set. The pivots of the Bitmap Nodes are aligned and the result can be seen in the SceneEditor: The Needle image is positioned correctly in the Gauge image.

drawing-7-1677217647.png

Don't forget to reset the Translation tool to "Pivot and Object".

drawing-7-1677217718.png


Back to the menu


Arc Align Example

1. Drag&drop a Group from the "Nodes 2D" Panel of the Toolbox to the SceneEditor or the Scene Tree. And add four Text Nodes to this group by dragging&dropping them onto the Group node in the SceneTree.

drawing-7-1677217869.png

2. Change the texts of the Text Nodes to "Text", "Text_1" etc. according to their names in the Scene Tree View.

drawing-7-1677217884.png

3. Drag&drop the Arc Align Behavior (which is a Control Behavior) from the Toolbox view onto the Group node in the SceneTree.

drawing-7-1677217902.png

4. Configure the Arc Align Behavior with a radius of 50 and AngleMinMax values of 0 and 90.

drawing-7-1677217920.png

5. The result can be seen in the Scene Editor view: All nodes are aligned like an arc from 0 to 90 degrees.

drawing-7-1677217929.png

Back to the menu



Enable Rendering Example

1. Drag&drop a TextButton Control from the Controls Panel of the Toolbox to the SceneEditor or the Scene Tree.

drawing-7-1677221451.png

2. Drag&drop the OnClick Behavior (which is a Control Behavior) from the Toolbox view onto the TextButton node in the SceneTree. Additionally, drag&drop the Enable Rendering Behavior (which is a Action - Property Behavior) from the Toolbox view onto the "Actions" field of the OnClick Behavior on the right side of the Scene Tree.

drawing-7-1677221472.png

3. Check the properties of the Enable Rendering Behavior. We want to change the visibility of the TextButton to invisible when it has been clicked (onClick), so the checkbox "Visible" has to remain unchecked.

drawing-7-1677221485.png

4. Save your solution and start the Player through the Play button (with the option "Generate and Play") in the Toolbar on the top to see the result.

drawing-7-1677221499.png

5. When you click on the TextButton you can see in the Player, it will get invisible. The behavior of the TextButton is like the behaviors that we have configured: OnClick -> EnableRendering (not visible)

Back to the menu


Format String Example

1. Drag&drop a TextButton Control from the Controls panel and a TextNode from the "Nodes 2D" Panel of the Toolbox to the SceneEditor or the Scene Tree. Set the TextButton's Text to "Format String".

drawing-7-1677221666.png

2. Drag&drop a Value Behavior (which is a Value Processing Behavior) from the Toolbox view onto the TextNode in the SceneTree. Set the Value Behavior's "AcceptValueEvent" property to true.

drawing-7-1677221695.png

3. Drag&drop a Format String Behavior (which is a Value Processing Behavior) from the Toolbox view onto the Value Behavior's Receivers.

drawing-7-1677221725.png

4. Set the Format String Behavior's "Text" property to "Score: %0.2f", in order to represent the value as formatted string.

drawing-7-1677221738.png

5. Drag&drop a Send Value as Event Behavior (which is a Action - Property Behavior) from the Toolbox view onto the TextButton's Actions on the right side of the SceneTree view.

drawing-7-1677221762.png

6. Configure the Send Value as Event Behavior's Value property to datatype Int32 and value 10. Adjust the behavior's TargetNode by clicking on the magnifying glass on the right of the property.

drawing-7-1677221773.png

7. Set the scene's TextNode as TargetNode for the Send Value as Event Behavior: After clicking the magnifying glass in the properties panel, the "Select Item" Dialog is opened. Select the scene's TextNode and press OK.

drawing-7-1677221811.png

8. Save your solution and start the Player through the Play button (with the option "Generate and Play") in the Toolbar on the top to see the result.

drawing-7-1677221826.png

9. When the TextButton is pressed, the Int32 value of 10 will be sent to the TextNode. This value is accepted by the TextNode and the behavior FormatString formats it to "Score: 10.00".

drawing-7-1677221861.png

Back to the menu




Forward Value Example
1. Drag&drop a Slider Control and a Text Value Control the Controls panel and a TextNode from the Controls Panel of the Toolbox to the Scene Editor or the Scene Tree.
drawing-7-1677222589.png

2. Position the Slider Control and Text Value Control in the Scene Editor View.

drawing-7-1677222616.png

3. Change the Text Value Control's "Format Text" Property to "Value: %d".

drawing-7-1677222688.png

4. Drag&drop a Forward Value Behavior (which is a Value Processing Behavior) from the Behaviors Panel of the Toolbox onto the Slider in the Scene Tree.

drawing-7-1677222705.png

5. Select the Forward Value Behavior in the right side of the Scene Tree view. Set the Forward Value Behavior's Target Node to the Text Value Control you have added to the scene in step 1 by clicking on the magnifying glass on the right of the input field and selecting the Text Value Control in the Choose Item dialog.

drawing-7-1677222726.png

After that, the Forward Value Behavior's Properties will look as follows.

drawing-7-1677222739.png

6. Save your solution and start the Player through the Play button (with the option "Generate and Play") in the Toolbar on the top to see the result.

drawing-7-1677222755.png

7. When manipulating the slider, the Value of the Text Value Control changes according to the alteration on the slider.

drawing-7-1677222799.png

Back to the menu




Hover - Hover Leave Example

1. Drag&drop a Text Control from the Controls Panel of the Toolbox to the Scene Editor or the Scene Tree and change its text to "Hover".

drawing-7-1677223245.png

2. Drag&drop a Hover Behavior (which is a Control Behavior) and a Handle Control State Behavior (which is a Control - Internal Behavior) from the Behaviors Panel of the ToolBox onto the Text Control in the SceneTree. The Handle Control State Behavior is needed in order for the Text Control to receive Input Events.

drawing-7-1677223271.png

3. Drag&drop a SetColor Behavior (which is an Action - Property Behavior) onto the Actions of the Hover Behavior on the right side of the SceneTree view.

drawing-7-1677223296.png

4. Select the Set Color Behavior and change the Color to red.

drawing-7-1677223305.png

5. Save your solution and start the Player through the Play button (with the option "Generate and Play") in the Toolbar on the top to see the result.

drawing-7-1677223315.png

6. When moving the mouse over the Text Control, the text color changes to red.

drawing-7-1677223338.png

7. Drag&drop a Hover Leave Behavior (which is a Control Behavior) onto the TextNode.

drawing-7-1677223364.png

8. Drag&drop a Set Color Behavior (which is an Action - Property Behavior) onto the Actions of the HoverLeave Behavior on the right side of the SceneTree view.

drawing-7-1677223385.png

9. Select the Set Color Behavior and change the Color to green.

drawing-7-1677223403.png

10. Save your solution and start the Player through the Play button (with the option "Generate and Play") in the Toolbar on the top to see the result.

drawing-7-1677223416.png

11. When moving the mouse over the Text Control, the text color changes to red (as it did before). When moving the mouse away again, the Text Control's color changes to green. Whenever you hover, it's getting red, when leaving, it's turning green.

drawing-7-1677223532.png

Back to the menu



Interpolate Value Example

1. Drag&drop a TextButton Control from the Controls panel and a TextNode from the "Nodes 2D" Panel of the Toolbox to the SceneEditor or the Scene Tree. Set the TextButton's Text to "Count to 10".

drawing-7-1677224131.png

2. Drag&drop a Value Behavior (which is a Value Processing Behavior) from the Behaviors Panel of the Toolbox onto the TextNode in the Scene Tree.

drawing-7-1677224160.png

3. Select the Value Behavior in the right side of the Scene Tree view. Set the Value Behavior's AcceptValueEvent Property to "true" by checking the checkbox.

drawing-7-1677224173.png

4. Drag&drop an Interpolate Value Behavior (which is a Value Processing Behavior) onto the Value Behavior's Receivers in the right side of the Scene Tree Panel.

drawing-7-1677224204.png

5. Select the Interpolate Value Behavior on the right side of the Scene Tree View and set the UnitsPerSecond to 1,00 in the Properties view on the bottom right.

drawing-7-1677224216.png

6. Drag&drop a Format String Behavior (which is a Value Processing Behavior) from the Toolbox onto the Interpolate Value Behavior's Receivers on the right side of the Scene Tree Panel.

drawing-7-1677224250.png

7. Select the Format String Behavior on the right side of the Scene Tree view and set the Text property to "%d" in the Properties view.

drawing-7-1677224267.png

8. Drag&drop a Send Value as Event Behavior (which is a Action - Property Behavior) from the Toolbox view onto the TextButton's Actions on the right side of the SceneTree view.

drawing-7-1677224298.png

9. Select the Send Value as Event Behavior on the right side of the Scene Tree Panel. Set the Value property to datatype "Float" and value "10" in the Properties view. Adjust the behavior's TargetNode by clicking on the magnifying glass on the right of the property.

drawing-7-1677224312.png

10. Set the scene's TextNode as TargetNode for the Send Value as Event Behavior: After clicking the magnifying glass in the properties panel, the "Select Item" Dialog is opened. Select the scene's TextNode and press OK.

drawing-7-1677224346.png

11. Save your solution and start the Player through the Play button (with the option "Generate and Play") in the Toolbar on the top to see the result.

drawing-7-1677224359.png

12. When clicking on the TextButton, the value 10 gets sent to the TextNode, but the TextNode doesn't change to 10 immediately. The Interpolate Value Behavior makes the TextNode count up from 0 to 10 in one step per second.

drawing-7-1677224502.png

Back to the menu


Move Node Example

 1. Drag&drop a TextButton Control from the Controls Panel of the Toolbox to the SceneEditor or the Scene Tree and change the Text to "Move Node"

drawing-7-1677223703.png

2. Select the TextButton in the Scene Tree View and delete all Behaviors that are automatically attached to the TextButton from the right side of the Scene Tree View.

drawing-7-1677223735.png

3. Drag&drop a Value Behavior (which is a Value Processing Behavior) and a Handle Control State Behavior (which is a Control - Internal Behavior) from the Behaviors Panel of the ToolBox onto the TextButton Control in the SceneTree. The Handle Control State Behavior is needed in order for the TextButton Control to receive Input Events.

drawing-7-1677223783.png

4. Select the Value Behavior on the right of the Scene Tree View and set the Value Behavior's AcceptValueEvent Property to "true" by checking the checkbox.

drawing-7-1677223801.png

5. Drag&drop the Move Node Behavior (which is a Value Processing - Transformation Behavior) from the Behaviors Panel of the ToolBox onto the Value Behavior's Receivers.

drawing-7-1677223828.png

6. Drag&drop an OnClick Behavior (which is a Control Behavior) from the Behaviors Panel of the ToolBox onto the TextButton Control.

drawing-7-1677223850.png

7. Drag&drop a Send Value as Event Behavior (which is a Action - Property Behavior) from the Behaviors Panel of the ToolBox onto the OnClick Behavior's Actions Property.

drawing-7-1677223875.png

8. Select the Send Value as Event Behavior on the right side of the Scene Tree View and set the value to datatype "Float" value "100,00" in the Properties view.

drawing-7-1677223899.png

9. Save your solution and start the Player through the Play button (with the option "Generate and Play") in the Toolbar on the top to see the result.

drawing-7-1677223911.png

10. When Clicking on the TextButton in the Player, the Button moves to position 50, 50.

drawing-7-1677223936.png

Back to the menu


OnClick Example

1. Drag&drop a SolidColorNode from the "Nodes 2D" Panel of the Toolbox to the SceneEditor or the Scene Tree.

drawing-7-1677228014.png

2. Drag&drop a OnClick Behavior (which is a Control Behavior) and a Handle Control State Behavior (which is a Control - Internal Behavior) from the Behaviors Panel of the ToolBox onto the SolidColorNode in the SceneTree. The Handle Control State Behavior is needed in order for the TextButton Control to receive Input Events.

drawing-7-1677228098.png

3. Drag&drop a Set Color SetColor Behavior (which is a Action - Property Behavior) from the Toolbox view onto the Actions of the OnClick Behaviors in the SceneTree.

drawing-7-1677228070.png

4. Select the Set Color Behavior and change the Color to red.

drawing-7-1677228106.png

5. Save your solution and start the Player through the Play button (with the option "Generate and Play") in the Toolbar on the top to see the result.

drawing-7-1677228115.png

6. When clicking on the SolidColorNode, the SolidColorNode's color changes to red.

drawing-7-1677228134.png

Back to the menu


OnPressed Example

 

1. Drag&drop a SolidColorNode from the "Nodes 2D" Panel of the Toolbox to the SceneEditor or the Scene Tree.

drawing-7-1677228338.png

2. Drag&drop a OnPressed Behavior (which is a Control Behavior) and a Handle Control State Behavior (which is a Control - Internal Behavior) from the Behaviors Panel of the ToolBox onto the SolidColorNode in the SceneTree. The Handle Control State Behavior is needed in order for the TextButton Control to receive Input Events.

drawing-7-1677228366.png

3. Drag&drop a Set Color SetColor Behavior (which is a Action - Property Behavior) from the Toolbox view onto the Actions of the OnPressed Behaviors in the SceneTree.

drawing-7-1677228409.png

4. Select the Set Color Behavior and change the Color to red.

drawing-7-1677228439.png

5. Save your solution and start the CGIPlayer through the Play button (with the option "Generate and Play") in the Toolbar on the top to see the result.

drawing-7-1677228460.png

6. When pressing the mouse left button on the SolidColorNode, the SolidColorNode's color changes to red.

drawing-7-1677228477.png

Back to the menu