930
Chapter 14: Properties
Example
This example has two parts. The first part is the first line of code, which registers the
#explode
handler for the
#collideAny
event. The second part is the
#explode
handler. When two models
in the cast member MyScene collide, the
#explode
handler is called and the
collisionData
argument is sent to it. The first nine lines of the
#explode
handler create the model resource
named SparkSource and set its properties. This model resource is a single burst of particles. The
tenth line of the handler creates a model named SparksModel using the model resource named
SparkSource. The last line of the handler sets the position of SparksModel to the position where
the collision occurred. The overall effect is a burst of sparks caused by a collision.
member("MyScene").registerForEvent(#collideAny, #explode, 0)
on explode me, collisionData
nmr = member("MyScene").newModelResource("SparkSource", #particle)
nmr.emitter.mode = #burst
nmr.emitter.loop = 0
nmr.emitter.minSpeed = 30
nmr.emitter.maxSpeed = 50
nmr.emitter.direction = vector(0, 0, 1)
nmr.colorRange.start = rgb(0, 0, 255)
nmr.colorRange.end = rgb(255, 0, 0)
nmr.lifetime = 5000
nm = member("MyScene").newModel("SparksModel", nmr)
nm.transform.position = collisionData.pointOfContact
end
See also
modelA
,
modelB
position (transform)
Usage
member(
whichCastmember
).node(
whichNode
).transform.position
member(
whichCastmember
).node(
whichNode
).getWorldTransform().\
position
transform
.position
Description
3D property; allows you to get or set the positional component of a transform. A transform
defines a scale, position and rotation within a given frame of reference. The default value of this
property is
vector(0,0,0)
.
A node can be a camera, group, light or model object. Setting the
position
of a node’s
transform defines that object’s position within the transform’s frame of reference. Setting the
position property of an object’s world relative transform using
getWorldTransform().position
defines the object’s position relative to the world origin. Setting the position property of an
object’s parent relative transform using
transform.position
defines the object’s position relative
to its parent node.
The
worldPosition
property of a model, light, camera or group object is a shortcut to the
getWorldTransform().position
version of this property for that object.
Summary of Contents for DIRECTOR MX 2004
Page 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Page 48: ...48 Chapter 2 Director Scripting Essentials...
Page 100: ...100 Chapter 4 Debugging Scripts in Director...
Page 118: ...118 Chapter 5 Director Core Objects...
Page 594: ...594 Chapter 12 Methods...
Page 684: ...684 Chapter 14 Properties See also DVD...
Page 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Page 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Page 1102: ...1102 Chapter 14 Properties...