User Guide
Chapter 20522
Use these commands to set up event handling:
Collisions
By attaching the collision modifier (#collision) to a model, you can enable that model to
automatically respond to collisions with other models. By using the properties of the collision
modifier, you can control the details of how the model responds to collisions. For more
information on collisions, see “Modifiers” on page 498.
Collision properties
When a collision occurs, it generates a
collideWith event.The collideWith event passes an
argument to the handler that is declared with the
registerForEvent or
setCollisionCallBack command. This argument is called a collisionData object and
contains a property list with detailed information about the collision.
These properties are included in the
collisionData object passed to the handler:
Command Description Returns
registerForEvent
(
eventName,
handlerName,
scriptInstance,
model)
The event eventName is one of the following:
#collideAny: Called when any collision occurs.
#collideWith: Called when a collision with a specific
model occurs and implicitly registered when
setCollisionCallback(...) is called. Equivalent to
calling
model.collision.setCollision
Callback
.
#timeMS: Sets up a time-based simulation callback using
the format
registerForEvent
(timeMS, handlerName, scriptInstance)
begin, period, repetitions
.
The
begin and period arguments are in milliseconds. If
repetitions is set to 0, the simulation continues
indefinitely.
#animationStarted: Called whenever a keyFrame or
bones motion begins.
#animationEnded: Called whenever a keyFrame or
bones motion ends.
Any user-defined symbol: Registers to receive any user-
defined event sent from a SendEvent call.
TRUE (1) if the operation
succeeds.
FALSE (0) if the
operation fails.
unregister
AllEvents()_
Unregisters all events. Nothing.
A Lingo error is generated
if the operation fails.
sendEvent
(
eventName,
arg1,arg2...)
Sends an event named eventName to all scripts registered
to receive it.
Similar to
sendAllSprites() except that the event is
delivered only to scripts that are registered to receive it.
Nothing.
A Lingo error is generated
if the operation fails.
Property Access Description
modelA Get One model in the collision.
If the Lingo script includes registration for collision with a
particular model,
modelA is that model.
modelB Get The second model in the collision.