Chapter 20
522
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.
Summary of Contents for DIRECTOR MX-USING DIRECTOR MX
Page 1: ...Using Director MX Macromedia Director MX...
Page 12: ...Contents 12...
Page 156: ...Chapter 4 156...
Page 202: ...Chapter 6 202...
Page 244: ...Chapter 7 244...
Page 292: ...Chapter 10 292...
Page 330: ...Chapter 12 330...
Page 356: ...Chapter 13 356...
Page 372: ...Chapter 14 372...
Page 442: ...Chapter 16 442...
Page 472: ...Chapter 18 472...
Page 520: ...Chapter 19 520...
Page 536: ...Chapter 20 536...
Page 562: ...Chapter 23 562...
Page 566: ...Chapter 24 566...
Page 602: ...Chapter 27 602...