This is an old revision of the document!
Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorShowElement
Behavior element behavior show/hide element if triggered.
If trigger evaluates to true the element is set visible and touchable others not.
This behavior can be used only once on an element.
Element class properties have the prefix showElement.
.
Set trigger to show element.
showElement.trigger
or showElement({id}).trigger
<string name='showElement.trigger'>@playerEnterSpot & @ghostPresent</string>
This behavior has no events.
This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace showElement
with showElement(id)
.
Set one or more show element parameters.
Parameter | Value | Description |
---|---|---|
shown | true,false | Show or hide element |
This is an example of using this action:
<action name='showElement.set'> <parameter name='shown'>true</parameter> </action>
Check one or more show element parameters. Action succeeds if all parameter value matches their respective show element parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a show element parameter matches (or not).
Parameter | Value | Description |
---|---|---|
shown | true,false | Element is shown or hidden |
This is an example of using this action:
<sequence> <action name='showElement.check'> <parameter name='shown'>true</parameter> </action> <!-- actions here run only if show element is shown --> </sequence>
This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace showElement
with showElement(id)
.
Check one or more show element parameters. Conditions returns true if all parameter value match their respective show element parameter. This condition is typically used to run an action or sequence of actions as long as show element conditions are true.
Parameter | Value | Description |
---|---|---|
showElement.shown | true,false | Element is shown or hidden |
This is an example of using this condition:
<action name='myAction' id='doing something'> <parameter name='showElement.shown'>true</parameter> <condition>showElement.check</condition> </action>
This behavior requires no other behaviors.
This behavior does support element class to be persistable (setPersistable). Saves shown state.
Since DragonScript Module Version 1.19
This example defines an element which contains a resources.
class MyElement extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorCollider collider public var ECBehaviorShowElement showElement func new() component = ECBehaviorComponent.new(this, null) collider = ECBehaviorCollider.new(this, component) showElement = ECBehaviorShowElement.new(this) end end
Using element class supporting adding behaviors the behavior can be added like this:
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorComponent'/> <behavior type='ECBehaviorCollider'/> <behavior type='ECBehaviorShowElement'> <!-- optional: use BaseGameApp trigger table. game can add more supported values. default is 'default' --> <string name='triggerTable'>default</string> <!-- optional: identifier of ECBehaviorTriggered to synchronize with or empty string to not synchronize. default is empty string. --> <string name='trigger.synchronize'>other</string> <!-- optional: use behavior tree with id instead of empty string --> <string name='behaviorTree'>second</string> <!-- optional: use state machine with id instead of empty string --> <string name='stateMachine'>second</string> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.name'>value</string> </behavior> </elementClass>