TGB/Behaviors/Callbacks
From TDN
This is a complete list of the callbacks available to use with behaviors in TGB. [edit] InitializationThese all are called at similar times, based on similar events, but they are different enough to all be necessary. For instance, some of these are called both in the game and editor, and some in the game only. [edit] onBehaviorAddCalled every time the behavior is added to an object, including in the editor. It should be used to initialize data. For instance, if a behavior requires mouse events, this would be a good place to call setUseMouseEvents on the object. [edit] onBehaviorRemoveCalled every time the behavior is removed from an object, including in the editor. Unless you are dynamically adding and removing the behavior from objects, it is not necessary to use this. If you are though, it is a good place to reset any data that was set in onBehaviorAdd. For instance, if you bind keys in onBehaviorAdd, you may want to unbind them in this method. [edit] onLevelLoadedParameters:
[edit] onLevelEndedParameters:
[edit] onAddToSceneParameters:
[edit] onRemoveFromSceneParameters:
[edit] Mouse EventsFor any of these events to be triggered, the object must have useMouseEvents enabled by calling setUseMouseEvents(true). Also, objects can call setMouseLocked(true) to lock the mouse with the object. This allows the object to receive all mouse event callbacks regardless of whether or not the mouse is within the bounding box of the object.
[edit] onMouseMoveCalled when the mouse moves within the object's bounding box. [edit] onMouseEnterCalled when the mouse enters the object's bounding box. [edit] onMouseLeaveCalled when the mouse leaves the object's bounding box. [edit] onMouseDownCalled when the left mouse button is clicked within the object's bounding box. [edit] onMouseDraggedCalled when the left mouse button is held down and the mouse moves within the object's bounding box. [edit] onMouseUpCalled when the left mouse button is released within the object's bounding box. [edit] onRightMouseDownCalled when the right mouse button is clicked within the object's bounding box. [edit] onRightMouseDraggedCalled when the right mouse button is held down and the mouse moves within the object's bounding box. [edit] onRightMouseUpCalled when the right mouse button is released within the object's bounding box. [edit] Game Events[edit] onCollisionParameters:
[edit] onWorldLimitParameters:
[edit] onUpdateThis is called every tick (32 milliseconds). It should be used only when necessary as it can have pretty serious performance implications. Because of this, it must be enabled with a call to enableUpdateCallback. It can be disabled by calling disableUpdateCallback. [edit] onPositionTargetThis is called when an object reaches its position target as set by setPositionTarget or moveTo. [edit] onRotationTargetThis is called when an object reaches its rotation target as set by setRotationTarget or rotateTo. [edit] onTimerThis is called when the timer set on an object via setTimerOn is triggered. [edit] Animation Events[edit] onAnimationStartThe animation has started to play. [edit] onAnimationEndThe animation has stopped playing. [edit] onFrameChangeParameters:
[edit] Trigger Events[edit] onEnterParameters:
[edit] onStayParameters:
[edit] onLeaveParameters:
|



