-
Notifications
You must be signed in to change notification settings - Fork 137
Callback Guide
Callbacks are scripting "hooks" that the engine provides, which allow you to write custom responses to events. Callbacks are optional, if the engine fires off a callback and nothing is defined for that event, then nothing happens.
A common callback that is used in many types of games is "onCollision". When the physics system registers a contact between two objects that have their collision properties properly defined and at least one of the objects has its callback turned on, you can define a script reponse for this event like so:
function SceneObject::onCollision(%this, %sceneObject, %collisionDetails)
{
}Depending on the namespace and what the object inherits from, you can define callbacks at the name, class/superclass, behavior, or object level.
Remember that the amount of callbacks available to an object depends on its inheritance tree. A Sprite, for example, is not listed here but has the callbacks available from SpriteBase, SceneObject, and SimObject.
SimObject
- onAdd
- onRemove
CompositeSprite
- onCustomLayout
ParticlePlayer
- onStopParticlePlayer
SceneObject
- onUpdate
- onWake
- onSleep
- onMoveToComplete
- onRotateToComplete
- onFadeToComplete
- onGrowToComplete
Trigger
- onEnter
- onStay
- onLeave
SpriteBase
- onAnimationEnd
Scene
- onSceneCollision
- onCollision
- onSceneEndCollision
- onEndCollision
- onSceneUpdate
- onSceneRender
- onAddToScene
- onRemoveFromScene
- onSafeDelete
BehaviorComponent
- onBehaviorAdd
- onBehaviorRemove
- onBehaviorMissing
SimComponent
- onComponentAdd
- onComponentRemove
SceneWindow
- onExtentChange
GuiCheckBoxCtrl
- onClick
GuiSceneObjectCtrl
- onDoubleClick
- onMouseEnter
- onMouseLeave
- onMouseDragged
GuiTabBookCtrl
- onTabSelected
GuiEditCtrl
- onClearSelected
- onAddSelected
- onAddNewCtrl
- onPreEdit
- onPostEdit
- onSelect
- onSelectionParentChange
- onPreSelectionNudged
- onPostSelectionNudged
- onSelectionMoved
- onTrashSelection
- onDelete
- onControlInspectPreApply
- onControlInspectPostApply
GuiMenuBarCtrl
- onAddMenuItem
- onOpen
- onClose
GuiCanvas
- onWake
GuiControl
- onWake
- onSleep
- onAction
- onDialogPush
- onDialogPop
GuiInputCtrl
- onInputEvent
GuiListBoxCtrl
- onUnselect
- onSelect
- onMouseDragged
- onDoubleClick
GuiMessageVectorCtrl
- urlClickCallback
GuiSliderCtrl
- onMouseDragged
GuiTextEditCtrl
- onMouseDown
- onMouseDragged
- onMouseUp
- onTab
- onValidate
- onReturn
- onLoseFirstResponder
GuiTreeViewCtrl
- onClick
- onDoubleClick
- onGetItemIcon
- onGetObjectText
- onPreReorder
- onPostReorder
ModuleManager
- onModuleRegister
- onModulePreLoad
- onModulePostLoad
- onModulePreUnload
- onModulePostUnload
PopupMenu
- onMessageReceived
GameCenter
- onAdd
- onRemove
- gameCenterAuthenticationChanged
main
- oniOSResignActive
- oniOSBecomeActive
- oniOSWillTerminate
- onExit
- oniOSOrientationToLandscapeLeft
- oniOSOrientationToLandscapeRight
- oniOSOrientationToPortrait
- oniOSOrientationToPortraitUpsideDown
GameConnection
- onConnectionAccepted
- onConnectRequestTimedOut
- onConnectionDropped
- onConnectRequestRejected
- onConnectionError
- onDrop
- setLagIcon
ServerQuery
- onServerQueryStatus
- onClearGameTypes
- onAddGameType
- onClearMissionTypes
- onAddMissionType
UndoManager
- onClear
- onRemoveUndo
- onUndo
- onRedo
- onAddUndo
ScriptMsgListener
- onMessageReceived
- onMessageObjectReceived
- onAddToQueue
- onRemoveFromQueue