Solving the Game


This is going to be a short section. Can you guess why? With the way the game works, there's really just one way to know when all of the matches have been made: when matchList is full.

When matchList has 16 entries, all of the cards have been added to it, and all of the matches have been made. Of course, there are other ways you could approach this, such as creating a variable and incrementing each time a match was made and then checking when its value reached 8. But since matchList is already available, you might as well use it. Currently the only thing it's doing is making it so you can't click on already matched cards.

1.

Right-click the 3D sprite and select Script from the context menu.

You can now modify the enterFrame handler to test if the matchList is full.

2.

Within the enterFrame handler, add the following conditional test. This test needs to go within the block of code that gets executed when a match occurs.

Currently, these three lines get executed:

 matchList.add(flippedList[1]) matchList.add(flippedList[2]) flippedList = [] 

You want to place the conditional test following these three lines so that the cards are added to matchList before you test it.

Add the if statement:

 if matchList.count() = 16 then  _movie.go("gameOver") end if 

Now, as soon as the final match is made and all the cards added to matchList, the movie will jump to the gameOver markerwhich you are about to create.

3.

Close the script window and save the movie.



Macromedia Director MX 2004. Training from the Source
Macromedia Director MX 2004: Training from the Source
ISBN: 0321223659
EAN: 2147483647
Year: 2003
Pages: 166
Authors: Dave Mennenoh

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net