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

on mSlide(me)<br />

vElapsed = the milliseconds - pThrowTime<br />

if vElapsed > pTimeToStop then<br />

vElapsed = pTimeToStop<br />

(the actorList).deleteOne(me)<br />

-- This will be the last time the puck moves<br />

end if<br />

vDistance = (pSpeed + (pAcceleration*vElapsed)/2) * vElapsed<br />

vWorldPosition = pThrowSpot + pDirection * vDistance<br />

pPuck.worldPosition = vWorldPosition<br />

end mSlide<br />

The puck stops<br />

Notice how the mSlide() handler checks whether the puck moment when the puck stops has passed. If it does not do<br />

this, the puck will come to a stop, and then start to accelerate in the opposite direction, as if friction behaved like an<br />

elastic band.<br />

Interpolation<br />

The interpolate() and interpolateTo() methods allow you to calculate a transform that is partway between one<br />

transform and another. To visualize what this means, download and launch the movie Interpolation.dir.<br />

Dragging the slider will move the blue half-cone from the between the two other half-cones<br />

Using interpolate()<br />

The syntax for the interpolate method is:<br />

outputTransform = transform1.interpolate(transform2, aPercentage)<br />

The value of aPercentage must be between 0.0 and 100.0. If you use a value outside this range, a script error occurs.<br />

The output is a transform, the scale of which will be vector(1.0, 1.0, 1.0), regardless of the scales of the input<br />

transforms. The position and rotation properties of the output transform will be a weighted average of the<br />

position and rotation of the two other transforms.<br />

If aPercentage is 0.0, then the output is a transform whose position and rotatation are identical to that of<br />

transform1. If aPercentage is 100.0, then the output is a transform whose position and rotatation are identical<br />

to that of transform2.<br />

Last updated 8/26/2011<br />

264

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

Saved successfully!

Ooh no, something went wrong!