User Manual: Event Handler Components

From Color Infection Wiki

Jump to: navigation, search


Contents


An event handler can be viewed a function. When a specific event occurs, the corresponding event handlers will be called with appropriate parameters.

To have a clear understanding of when an event handler will be called, see event handling occasions.

All event handler entities have a code sinppet property.

  • Code Sinppet: The code snippet contains some function callings.

On Level (Before Initializing | After Initialized)

OnLevelBeforeInitializing event handlers are called at the beginning of initializing a level. At this time, the physics world has not built up, all entities have not initialized yet.

OnLevelAfterInitialized event handlers are called at the end of initializing a level. At this time, the physics world has already built up, all entities have already initialized..

On Level (Before Updating | After Updated)

OnLevelBeforeUpdating event handlers are called at the beginning of updating a level.

OnLevelAfterUpdated event handlers are called at the end of updating a level.

On Entity (Initialized | Updated | Destroyed)

OnEntityInitialized event handlers are called after an entity is initialized.

OnEntityUpdated event handlers are called after an entity is updated.

OnEntityDestroyed event handlers are called when an entity is destroyed.

Input Parameters:

Entity
the entity the corresponding event happens on

On Joint Reach (Lower | Upper) Limit

OnJointReachLowerLimit event handlers are called when an joint reaches the lower limit. Here the joint can be a hinge or a slider.

OnJointReachUpperLimit event handlers are called when an joint reaches the upper limit. Here the joint can be a hinge or a slider.

Input Parameters:

The Joint
the joint the corresponding event happens on

On (Entity | Entity Pair | World) Timer

OnEntityTimer is a timer event handler special for some entities. An OnEntityTimer event handler can have several input entity assigner properties and has a The Entity parameter. When the event handler is triggered, the code snippet will be called for all the entities assigned by all the input entity assigners.

OnEntityPairTimer is a timer event handler special for entity pairs. An OnEntityPairTimer event handler can have several input entity apir assigner properties and has a Entity 1 and Entity 2 parameter pair. When the event handler is triggered, the code snippet will be called for all the entity pairs assigned by all the input entity pair assigners.

OnWorldTimer is a timer event handler special for the world.

Input Parameters (for OnEntityTimer):

Calling Times
how many times this event handler is called. This is sometimes useful when the Only Run Once property is set false.
The Entity
the entity the corresponding event happens on

Input Parameters (for OnEntityPairTimer):

Calling Times
how many times this event handler is called. This is sometimes useful when the Only Run Once property is set false.
Entity 1
one entity
Entity 2
another entity

Input Parameters (for OnWorldTimer):

Calling Times
how many times this event handler is called. This is sometimes useful when the Only Run Once property is set false.

All timer event handler entities have some more properties:

  • Only Run Once: true for only run once, false for run unlimited times
  • Timer Interval: the timer interval in simulation steps.

On Shape Mouse (Click | Down | Up | Move | Enter | Out)

These mouse event handlers are called for visible shapes. If there are many shapes under the mouse, only the topmost one can receive the mouse event.

Input Parameters:

The shape
the shape the corresponding event happens on
World X
mouse position x when the corresponding event happens
World Y
mouse position y when the corresponding event happens
Is Button Down
whether or not the left mouse button is pressed
Is Ctrl Down
whether or not the Ctrl key is hold
Is Shift Down
whether or not the Shift key is hold
Is Alt Down
whether or not the Alt key is hold

On Physics Shape Mouse (Down | Up)

These mouse event handlers are called for physics shapes (include invisible ones). If there are many physics shapes under the mouse, all these shapes will receive the mouse event.

Input Parameters:

The Physics Shape
the physics shape the corresponding event happens on
World X
mouse position x when the corresponding event happens
World Y
mouse position y when the corresponding event happens
Is Button Down
whether or not the left mouse button is pressed
Is Ctrl Down
whether or not the Ctrl key is hold
Is Shift Down
whether or not the Shift key is hold
Is Alt Down
whether or not the Alt key is hold

OnTwoPhysicsShape (Start | Keep | Stop) Contacting

These keyboard event handlers are called when two physics shapes are contacting.

Input Parameters:

Physics Shape 1
one physics shape
Physics Shape 2
another physics shape
Steps
how many steps since the contact is built

On World Mouse (Click | Down | Up | Move)

These mouse event handlers are called for world.

Input Parameters:

World X
mouse position x when the corresponding event happens
World Y
mouse position y when the corresponding event happens
Is Button Down
whether or not the left mouse button is pressed
Is Ctrl Down
whether or not the Ctrl key is hold
Is Shift Down
whether or not the Shift key is hold
Is Alt Down
whether or not the Alt key is hold

On Key (Down | Up | Hold)

These keyboard event handlers are called when a keyboard event occurs.

Input Parameters:

Key Code
the key code
Char Code
the char code
Is Button Down
whether or not the left mouse button is pressed
Is Ctrl Down
whether or not the Ctrl key is hold
Is Shift Down
whether or not the Shift key is hold
Is Alt Down
whether or not the Alt key is hold

All keyboard event handler entities have one more property:

  • The Keys: which keys will trigger this event handler.