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 />

vBall1 = member("Physics").getRigidBody("ball1")<br />

vRoom = member("Physics").getRigidBody("room")<br />

member("Physics").disableCollision(vBall1, vRoom)<br />

This code disables collision detection only between the red ball and the room. Collisions between the white ball and<br />

the red ball will still be detected. What do you predict will happen when you click on the red ball?<br />

Collision disabled pairs<br />

You can use physicsMember.getCollisionDisabledPairs() to retrieve a list of the pairs of objects for which you have<br />

explicitly disabled collision management using disableCollision(). Try the following command in the Message<br />

window.<br />

trace (member("Physics").getCollisionDisabledPairs())<br />

-- [[rigidBody("room"), rigidBody("ball1")]]<br />

Changing the callback handler<br />

You can only have one registered collision callback handler at a time. You can change the callback handler by<br />

registering a new one. For example, launch the BallRoom.dir movie, then execute the following command in the<br />

Message window:<br />

member("Physics").registerCollisionCallback(#TestCallback)<br />

This code will make the on TestCallback() in the Test Callback movie script take over the handling of callback<br />

events.<br />

If you want to stop all callback event detection completely, you can use physicsMember.removeCollisionCallback().<br />

This function stops triggering callbacks to the handler registered earlier. To test this behavior, execute the following<br />

command in the Message window:<br />

member("Physics").removeCollisionCallback()<br />

Hold the Option/Alt key down and click on the red ball. No collision ContactReports will appear in the Message<br />

window, and you will see no Foul warning. (You will still lose a point each time you click, because the scoring system<br />

will not be told of any valid interactions before the balls both come to a halt. See the mStartScoring(),<br />

mCheckForSleep() and mCheckCollisions() handlers for details on how the scoring is treated.)<br />

Joints and springs<br />

The Dynamiks xtra provides for four different ways to join to objects together in a way that mutually constrains their<br />

motion.<br />

Angular joints allow objects to rotate freely to any angle, but constrain the relative linear movements of two objects.<br />

See “Angular joint properties” on page 334 for details on how to modify an angular joint after you have created it.<br />

Linear joints allow objects to move freely in any linear direction, but constrain the relative rotations of two objects.<br />

See “Linear joint properties” on page 335 for details on how to modify a linear joint after you have created it.<br />

Springs create a compression or an expansion force between two objects which tend to move them until they are at<br />

a given resting distance from each other. See “Spring properties” on page 336 for details on how to modify a spring<br />

after you have created it.<br />

“D6Joints” on page 338 allow you to control movement of two different types along 3 different axes giving six<br />

degrees of freedom.<br />

Last updated 8/26/2011<br />

330

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

Saved successfully!

Ooh no, something went wrong!