The fifth and almost final part of my iPhone Game Development tutorial series is ready to download. This week’s video is almost 3 hours (ouch I know) but it’ll be worth it as you put together BlackJack. The main topics include…
- NSDictionary (for pairing up card names with a value, like SpadeAce = 11)
- Rearranging the contents of an array (for shuffling the deck)
- NSNotificationCenter, the proper way for a subclass in Objective C to send a message to a parent class (like root or parent in Actionscript)
- Adding dynamic objects (in this case card images) without using Interface Builder
- Tagging those objects with an ID so we can use viewWithTag to refer back to them later in touch events (specifically with hitTest or CGRectIntersectsRect)
- Flip animations for the card ( UIViewAnimationTransitionFlipFromLeft )
- Unloading / reloading a view (and memory issues with that)
And as you can see from the image below, we’re using a UIToolBar for the buttons to Hit or Stay when it is the players turn, but the game also switches to dealer mode. In which case, the first card is turned over, and the dealer automatically plays (Vegas-style, where the dealer hits until he’s over 16).
Finally don’t forget that ALL this iPhone training also applies to the iPad.