Drag[en]gine Script Module DragonScript
1.23
|
Behavior element behavior adding animation support. More...
Classes | |
class | BlockListenerFactory |
Factory creating listeners using block. More... | |
class | BooleanListener |
Implementation of behavior instance listener using BooleanBehaviorListener. More... | |
class | DefaultListener |
Default implementation of behavior instance listener. More... | |
class | Instance |
Behavior instance. More... | |
interface | Listener |
Listener for behavior instance events. More... | |
interface | ListenerFactory |
Factory creating listeners. More... | |
Additional Inherited Members | |
Public Member Functions inherited from Dragengine.Scenery.DefaultECBehavior | |
void | assignInstanceIndex (int instanceIndex) |
Assign instance index. More... | |
void | dispose () |
Dispose of behavior. 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... | |
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 animation support.
Playings back an animation using an animator for an ECBehaviorComponent. By default the ECBehaviorComponent with empty identifier is animated. Multiple ECBehaviorAnimated can be added targeting different ECBehaviorComponent using their identifier. It is also possible to add multiple ECBehaviorAnimated manipulating the same ECBehaviorComponent as long as the animators used are properly crafted. This can be used for example to add overlayed animations like gestures onto an actor.
To use this behavior make sure to add first the ECBehaviorComponent to animate. The example below adds to components and animates each using an own animator.
Because multiple animator behaviors can animate the same component behavior the animator behavior has an own identifier. In the example above the first string parameter is the animator behavior identifier while the second string parameter is the component behavior identifier to animate.
Element class properties have the prefix "animated{(id)}.".
Behavior elements and other behaviors can add listeners to the ECBehaviorAnimated. Listeners are notified if the animation starts playing and when it stops playing. This can be used to synchronize actions to these events. ECBehaviorAnimated can also use trigger targets so listeners are not always required.
Another use for listeners is update animator controllers not handled by ECBehaviorAnimated itself. ECBehaviorAnimated calls AnimatorInstance.apply() before it exits thinking. If other behaviors modify the animator controller later on they need to call AnimatorInstance.apply() again. If multiple behaviors affect the same animated component this can put strain on the game engine modules and reduce performance. For this reason listeners are also asked to update animator controllers. This allows multiple behaviors to update individual controllers with AnimatorInstance.apply() to be called only once.
It is important to note that using listeners behaviors are asked to update animator controllers before their think() method is called. For such behaviors it is best to do their thinking inside the listener call avoiding think() to be used at all.
A typical usage pattern for such behaviors is to locate the animator controller to update during construction time and to manipulated the controllers inside updateControllers(). This example shows this concept:
This behavior does require the element class to be persistable (setPersistable).