unFlip = function(inTile1, inTile2, inPlayerOrOpponent) {
if (inTile1 != null) {
dwr.util.byId("tile" + inPlayerOrOpponent + "_" + inTile1).src =
inMemoria.tileImages[0].src;
}
if (inTile2 != null) {
dwr.util.byId("tile" + inPlayerOrOpponent + "_" + inTile2).src =
inMemoria.tileImages[0].src;
}
if (inPlayerOrOpponent == "Player") {
inMemoria.playerFlippedTile1 = null;
inMemoria.playerFlippedTile2 = null;
inMemoria.playerProcessClicks = true;
}
} // End unFlip().
The arguments of this method indicate which tiles are flipped and whether we??™re unflipping
player tiles or opponent tiles. Unflipping the tiles is simply a matter of changing their src
attribute to the unflipped tile image. Also, if we??™re unflipping player tiles, we clear the two
fields that record what tiles are flipped and ensure that player clicks will be processed again.
By making this a separate method with this structure, we can use this to unflip both player
and opponent tiles, and it allows us to do this generically whether two matching tiles were just
found, two tiles that don??™t match are being unflipped, or a tile is already unflipped because the
player clicked it twice in a row.
With unflip() out of the way, we can pick up where we left off in tileClick().
Pages:
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748