07.12.2012 Views

Adobe Director Basics

Adobe Director Basics

Adobe Director Basics

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ADOBE DIRECTOR BASICS<br />

3D: Controlling action<br />

-- Lingo syntax<br />

member("3D").model("HighImpact").addModifier(#collision)<br />

put member("3D").model("HighImpact").modifier<br />

-- [#collision]<br />

// JavaScript syntax<br />

member("3D").getPropRef("model", 2).addModifier(symbol("collision"));<br />

trace(member("3D").getPropRef("model", 2).modifier)<br />

// <br />

Removing the modifier<br />

You can use the command aModel.removeModifier() to remove the #collision modifier.<br />

-- Lingo syntax<br />

member("3D").model("HighImpact").removeModifier(#collision)<br />

// JavaScript syntax<br />

member("3D").getPropRef("model", 2).removeModifier(symbol("collision"));<br />

Collision properties<br />

Adding the collision modifier to a model gives you access to four properties:<br />

model.collision.enabled: TRUE or FALSE (TRUE by default). If TRUE, then collisions between this model and other<br />

models will trigger a collision event.<br />

model.collision.mode: #sphere, #box or #mesh. Determines what form of simplified geometry is used for collision<br />

detection. The default #sphere mode is the fastest and #mesh the slowest.<br />

model.collision.resolve: TRUE or FALSE (TRUE by default). If TRUE and you attempt to move this model to a position<br />

where a collision is detected with another model, then this model will be moved back in a straight line along its<br />

trajectory to a position where no collision is detected.<br />

model.collision.immovable:TRUE or FALSE (FALSE by default). Setting this property to TRUE will not prevent you<br />

from moving the model. It simply tells the collision modifier that any movement of this model is to be ignored. To<br />

improve performance, the collision modifier will not check whether any immovable models are in collision with<br />

each other.<br />

Collision events<br />

You can generate a callback when a collision occurs using any of the following methods:<br />

model.collision.setCollisionCallBack()<br />

model.registerScript()<br />

member3D.registerForEvent()<br />

The setCollisionCallBack(aHandler, aCodeObject) method is a shortcut for<br />

model.registerScript(#collideWith,aHandler, aCodeObject). You can use<br />

registerForEvent(#collideAny, aHandler, aCodeObject) to generate a callback whenever any collision is<br />

detected between any two models with the collision.modifier.<br />

collisionData<br />

When a collision is detected, the collision modifier will call any handler that is registered for collision events and send<br />

a collisionData object as a parameter to the call. The collisionData object has four properties.<br />

collisionData.modelA is one of the models involved in the collision.<br />

Last updated 8/26/2011<br />

281

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!