489
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
pointToChar()
Syntax
pointToChar(sprite
spriteNumber
,
pointToTranslate
)
Description
Function; returns an integer representing the character position located within the text or field
sprite
spriteNumber
at screen coordinate
pointToTranslate
, or returns -1 if the point is not
within the text.
This function can be used to determine the character under the cursor.
Example
This Lingo displays the number of the character being clicked, as well as the letter, in the
Message window:
property spriteNum
on mouseDown me
pointClicked = the mouseLoc
currentMember = sprite(spriteNum).member
charNum = sprite(spriteNum).pointToChar(pointClicked)
actualChar = currentMember.char[charNum]
put "Clicked character" && charNum & ", the letter" && actualChar
end
See also
mouseLoc
,
pointToWord()
,
pointToItem()
,
pointToLine()
,
pointToParagraph()
Содержание DIRECTOR MX-LINGO DICTIONARY
Страница 1: ...Lingo Dictionary Macromedia Director MX...
Страница 756: ...Index 756...