Tutorial 6: Action on Param
ActionOnParam Blackbox is one of the most versatile of all blackboxes. It is used to perform an action from those available for a particular data type. You can find it in the BasicActions category in the Blackboxes tab within the panel LogicChart.
The Blackbox has an input parameter called target which can be of the following types: number, boolean, string, Vector2D, Scene, Layer, Object2D, Bitmap, Sprite or Text. When an element or a parameter is dragged from the Asset Manager or from the Parameters tab or from another Blackbox, whose type is any of the listed before, and released on the target input parameter of ActionOnParam, then the action property of the Blackbox shows a list of all possible actions for that data type. In the next image you can see what happens when you drag and drop a Sprite to the target input parameter.
Automatically, the action property is completed with the actions that can be performed with a Sprite type parameter. By default the first action is selected, which in the example above is clone. As clone action allows to assign a parent to depend on, the Blackbox automatically shows an Object2D input parameter called parent . It also produces an Sprite output parameter called clone with the cloned sprite. In the next picture you can see how to modify the Blackbox in the case of selecting the action translate instead of clone.
If translate action is selected, the ActionOnParam Blackbox requests an input parameter of type Vector2D to enter the offset to translate, and generates a Vector2D output parameter called positionResult with the Sprite new position.
The following figure shows the possible actions on a number parameter. As the number is a basic data type, the possible actions are more limited.
The ActionOnParam Blackbox has a unique activator called do and two triggers:
- done: is triggered when the execution of the selected action is complete.
- fail: is triggered when for some reason the action can not be performed.
so its use is really simple. With this Blackbox you can obtain a lot of functionality and much greater level of detail than other more general blackboxes.19/05/2014 / No Comments