Game Development Reference
In-Depth Information
If the user selects the same coin, we simply set that coin spinning again and set
isFirstCoinSelected to false. However, if the user selects a different coin, it is time to switch the
coins. The first thing we do is set acceptingInput to false , so the user doesn't interrupt us as the
animations are happening. We also want to decrement the number of remaining turns and inform
the delegate that this has happened. We set isFirstCoinSelected to false, because the next time
this method is called, there should be no coin selected. After recording the coordinate of the second
coin in the variable secondSelectedCoin , we stop the selected coin and call doSwitch:With: , passing
in the first and second selected coins. The task doSwitch is shown in in Listing 4-25 in the following
section and is responsible for creating the animations of the coins trading places.
This brings us to a discussion of how animations are created without using the static UIView tasks
described earlier.
UIView that helped create animations. These tasks
UIView tasks.
4-8 shows the animation of the coins trading places.
Figure 4-8. Coins switching locations
The coin in the first column and second row (a square) is being switched with the coin in the second
column and the last row (a triangle). Each coin shrinks until it is too small to see. Then the type of
coin switches before growing back to normal size. This is implemented in the task doSwitch:With: ,
shown in Listing 4-25.
 
Search WWH ::




Custom Search