iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK
by Kyle Richter, Joe Keeley
Cactus Interaction
There are two possible outcomes of a cactus spawning: Either the user has hit the cactus within the two-second limit or the user has failed to hit it. In the first scenario cactusHit: is called in response to a UIControlEventTouchDown on the cactus button. When this happens, the cactus is quickly faded off the screen and then removed from the superView. Using the option UIViewAnimationOptionsBeginFromCurrentState will ensure that any existing animations on this cactus are cancelled. The score is incremented by one and displayNewScore: is called to update the score on the screen; more on that later in this section. After a cactus has been hit, a key step is spawning the next cactus. This is done in the same fashion as in viewDidLoad ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access