Drag[en]gine Script Module DragonScript
1.23
|
Behavior element behavior adding support to switch component skins. More...
Classes | |
class | BooleanListener |
Boolean listener switching skin. More... | |
class | Instance |
Behavior instance. More... | |
Public Member Functions | |
void | dispose () |
Dispose of behavior. More... | |
ECPInteger | getActive () |
Index of initially active skin property. More... | |
ECPBoolean | getClamp () |
Clamp property. More... | |
ECBehaviorComponent | getComponent () |
Component behavior. More... | |
ECPSkinList | getSkins () |
Skins property. More... | |
ECPString | getTexture () |
Texture property. More... | |
void | listen (ECBehaviorAnimated behavior, BooleanListener.SwitchType switchType) |
Add listener factory to ECBehaviorAnimated behavior. More... | |
void | listen (ECBehaviorEvaluate behavior, BooleanListener.SwitchType switchType) |
Add listener factory to ECBehaviorEvaluate behavior. More... | |
void | listen (ECBehaviorTouching behavior, BooleanListener.SwitchType switchType) |
Add listener factory to ECBehaviorTouching behavior. More... | |
void | listen (ECBehaviorTouchSensor behavior, BooleanListener.SwitchType switchType) |
Add listener factory to ECBehaviorTouchSensor behavior. More... | |
void | listen (ECBehaviorTriggered behavior) |
Add listener factory with SwitchType.nextOnOff to ECBehaviorTriggered behavior. More... | |
void | listen (ECBehaviorTriggered behavior, BooleanListener.SwitchType switchType) |
Add listener factory to ECBehaviorTriggered behavior. More... | |
void | listen (ECBehaviorTwoStateAnimated behavior, BooleanListener.SwitchType switchType) |
Add listener factory to ECBehaviorTwoStateAnimated behavior. More... | |
ECBehaviorSkinSwitcher | new (BehaviorElementClass eclass, ECBehaviorComponent component) |
Create behavior element class. More... | |
ECBehaviorSkinSwitcher | new (BehaviorElementClass eclass, ECBehaviorComponent component, String id) |
ECBehaviorSkinSwitcher | new (BehaviorElementClass eclass, ECBehaviorComponent component, String id, String subId) |
ECBehaviorSkinSwitcher | new (BehaviorElementClass eclass, ECBehaviorComponent component, String id, String subId, String prefix) |
Public Member Functions inherited from Dragengine.Scenery.DefaultECBehavior | |
void | assignInstanceIndex (int instanceIndex) |
Assign instance index. More... | |
String | getBehaviorID () |
Unique identifier of behavior. More... | |
String | getID () |
Identifier. More... | |
int | getInstanceIndex () |
Instance index. More... | |
void | loadSupportedData (String identifier, PersistencyEnvironment env, FileReader reader, ECBehaviorInstance instance) |
Load instance data of another behavior. More... | |
bool | supportsBehaviorID (String identifier) |
Behavior supports loading instance data of another behavior. More... | |
Public Member Functions inherited from Dragengine.Scenery.ECBehavior | |
ECBehaviorInstance | createInstance (BehaviorElement element) |
Create Behavior instance. More... | |
Static Public Member Functions | |
static ECBehaviorSkinSwitcher | getBehaviorIn (BehaviorElementClass eclass) |
Get behavior in element class or null if absent. More... | |
Public Attributes | |
ECPInteger | pActive |
ECPBoolean | pClamp |
ECBehaviorComponent | pComponent |
ECPSkinList | pSkins |
ECPString | pTexture |
Additional Inherited Members | |
Protected Member Functions inherited from Dragengine.Scenery.DefaultECBehavior | |
DefaultECBehavior | new (BehaviorElementClass eclass) |
Create default composeable behavior with empty identifier. More... | |
DefaultECBehavior | new (BehaviorElementClass eclass, String id) |
Create default composeable behavior. More... | |
void | setBehaviorID (String identifier) |
Set behavior identifier. More... | |
void | useClassNameAsBehaviorID () |
Set behavior identifier to "<class-name>:<identifier>". More... | |
void | useFullyQualifiedClassNameAsBehaviorID () |
Set behavior identifier to "<fully-qualified-class-name>:<identifier>". More... | |
Behavior element behavior adding support to switch component skins.
If a texture name is specified the matching component texture skin is switched instead of switching the skin for the entire component.
Switching skins can be used for example with monitors which show an offline skin and if used by the player switch to one or more online skins. Another use case is to create damageable objects which change skin the more they are damaged.
To use this behavior assign one or more skins to it. The first skin is used as the starting skin. By calling setActive() the active skin can be selected using the index of the skin in the list of defined skins. Furthermore activateNext() and activatePrevious() can be used to cycle through skins.
Optionally this behavior can be attached to various other behaviors supporting BooleanBehaviorListener. By doing so cycling though skins is attached to listener events called by other behaviors.
Skin switcher is set by default to wrap index around at the begin and end of the skin list. This allows to indefinitely cycle through all skins. By setting the "clamp" element class property to true the skins can cycle only once not wrapping around.
The example below switches the skin of a texture if the animated state become activate:
Multiple instances of ECBehaviorSkinSwitcher can be used for example to switch skins of multiple component textures. To use multiple instances use code like this in your subclass constructor:
Element class properties have the prefix "skinSwitcher{(id)}.".
This behavior does support element class to be persistable (setPersistable). Saves active skin index.
void Dragengine.Scenery.ECBehaviorSkinSwitcher.dispose | ( | ) |
Dispose of behavior.
Reimplemented from Dragengine.Scenery.DefaultECBehavior.
ECPInteger Dragengine.Scenery.ECBehaviorSkinSwitcher.getActive | ( | ) |
Index of initially active skin property.
|
static |
Get behavior in element class or null if absent.
Use this method to check if a particular BehaviorElementClass contains a behavior of type ECBehaviorCollider.
ECPBoolean Dragengine.Scenery.ECBehaviorSkinSwitcher.getClamp | ( | ) |
Clamp property.
If set to true prevents wrapping around when cycling skins.
ECBehaviorComponent Dragengine.Scenery.ECBehaviorSkinSwitcher.getComponent | ( | ) |
Component behavior.
ECPSkinList Dragengine.Scenery.ECBehaviorSkinSwitcher.getSkins | ( | ) |
Skins property.
ECPString Dragengine.Scenery.ECBehaviorSkinSwitcher.getTexture | ( | ) |
Texture property.
Name of texture to affect or empty string to affect entire component.
void Dragengine.Scenery.ECBehaviorSkinSwitcher.listen | ( | ECBehaviorAnimated | behavior, |
BooleanListener.SwitchType | switchType | ||
) |
Add listener factory to ECBehaviorAnimated behavior.
void Dragengine.Scenery.ECBehaviorSkinSwitcher.listen | ( | ECBehaviorEvaluate | behavior, |
BooleanListener.SwitchType | switchType | ||
) |
Add listener factory to ECBehaviorEvaluate behavior.
void Dragengine.Scenery.ECBehaviorSkinSwitcher.listen | ( | ECBehaviorTouching | behavior, |
BooleanListener.SwitchType | switchType | ||
) |
Add listener factory to ECBehaviorTouching behavior.
void Dragengine.Scenery.ECBehaviorSkinSwitcher.listen | ( | ECBehaviorTouchSensor | behavior, |
BooleanListener.SwitchType | switchType | ||
) |
Add listener factory to ECBehaviorTouchSensor behavior.
void Dragengine.Scenery.ECBehaviorSkinSwitcher.listen | ( | ECBehaviorTriggered | behavior | ) |
Add listener factory with SwitchType.nextOnOff to ECBehaviorTriggered behavior.
void Dragengine.Scenery.ECBehaviorSkinSwitcher.listen | ( | ECBehaviorTriggered | behavior, |
BooleanListener.SwitchType | switchType | ||
) |
Add listener factory to ECBehaviorTriggered behavior.
void Dragengine.Scenery.ECBehaviorSkinSwitcher.listen | ( | ECBehaviorTwoStateAnimated | behavior, |
BooleanListener.SwitchType | switchType | ||
) |
Add listener factory to ECBehaviorTwoStateAnimated behavior.
ECBehaviorSkinSwitcher Dragengine.Scenery.ECBehaviorSkinSwitcher.new | ( | BehaviorElementClass | eclass, |
ECBehaviorComponent | component | ||
) |
Create behavior element class.
ECBehaviorSkinSwitcher Dragengine.Scenery.ECBehaviorSkinSwitcher.new | ( | BehaviorElementClass | eclass, |
ECBehaviorComponent | component, | ||
String | id | ||
) |
ECBehaviorSkinSwitcher Dragengine.Scenery.ECBehaviorSkinSwitcher.new | ( | BehaviorElementClass | eclass, |
ECBehaviorComponent | component, | ||
String | id, | ||
String | subId | ||
) |
ECBehaviorSkinSwitcher Dragengine.Scenery.ECBehaviorSkinSwitcher.new | ( | BehaviorElementClass | eclass, |
ECBehaviorComponent | component, | ||
String | id, | ||
String | subId, | ||
String | prefix | ||
) |
ECPInteger Dragengine.Scenery.ECBehaviorSkinSwitcher.pActive |
ECPBoolean Dragengine.Scenery.ECBehaviorSkinSwitcher.pClamp |
ECBehaviorComponent Dragengine.Scenery.ECBehaviorSkinSwitcher.pComponent |
ECPSkinList Dragengine.Scenery.ECBehaviorSkinSwitcher.pSkins |
ECPString Dragengine.Scenery.ECBehaviorSkinSwitcher.pTexture |