macromedia DIRECTOR MX 1002004 training from the source [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

macromedia DIRECTOR MX 1002004 training from the source [Electronic resources] - نسخه متنی

Dave Mennenoh

نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
افزودن یادداشت
افزودن یادداشت جدید











Pausing the Rotation


Right now, when you flip two cards over and don't make a match, they instantly flip back. It's so fast, you hardly have enough time to see what the second card was. In this section you'll add a simple timing mechanism to the game loop that will pause the rotation for half a second before the cards flip back.


1.

Open your copy of the memory game from your project_four folder. Right-click the 3D sprite and select Script from the context menu. Add the following property declaration at the top of the script:


property flipPause

2.

In the enterFrame handler, initialize flipPause within the same block of code that executes when a match is not made. This is the block of code that sets up the two transformobjects. You can add the code right after the line that sets transformPercent to 0:


flipPause = _system.milliseconds + 500

This sets flipPause to half a second later than the current time.

3.

Add the following conditional test immediately after the line that checks if isRotating is equal to 2, and immediately before the two lines that interpolate the two cards:


if _system.milliseconds > flipPause then

4.

Finally, add an end if statement to the end of the enterFrame handler, to close the timing test conditional statement.

For reference, the enterFrame handler should now look like this:


on enterFrame me
if isRotating = 1 then
whichMod.transform = origTransform.interpolate(finalTransform, ¬
transformPercent)
transformPercent = transformPercent + 5
if transformPercent > 100 then
isRotating = 0
if flippedList.count() = 2 then
if _global.solveList[flippedList[1]] = ¬
_global.solveList[flippedList[2]] then
matchList.add(flippedList[1])
matchList.add(flippedList[2])
flippedList = []
else
isRotating = 2
whichMod = wrld.model("c" & string(flippedList[1]))
whichMod2 = wrld.model("c" & string(flippedList[2]))
origTransform = whichMod.transform.duplicate()
finalTransform = whichMod.transform.duplicate()
finalTransform.rotation.y = 180
origTransform2 = whichMod2.transform.duplicate()
finalTransform2 = whichMod2.transform.duplicate()
finalTransform2.rotation.y = 180
transformPercent = 0
flipPause = _system.milliseconds + 500
end if
end if
end if
end if
if isRotating = 2 then
if _system.milliseconds > flipPause then
whichMod.transform = origTransform.interpolate(finalTransform, ¬
transformPercent)
whichMod2.transform = origTransform2.interpolate(finalTransform2, ¬
transformPercent)
transformPercent = transformPercent + 5
if transformPercent > 100 then
isRotating = 0
flippedList = []
end if
end if
end if
end

5.

Rewind and play the movie.

When you flip over two cards that don't make a match, the cards now pause for half a second before flipping back.

With that out of the way, let's add a timer. This will act as a scoring device, by showing how fast you complete the game.



/ 165