Game Development Reference
In-Depth Information
In Figure
4-1
, after any initial setup, the application waits for a user to take some action. When the user
does something, the game state is updated, and animations are created to reflect the user's action.
The animation created by this user action can be simple, such as highlighting a selection, or complex,
like an entire physics simulation. After the animation is completed, the application tests to see whether
the end of the game has been reached. If it has not, the application once again waits for user input.
In this chapter, you will explore how to create a game that follows the process outlined in Figure
4-1
.
You will also look at the details of getting content onto the screen and creating animations.
Exploring How to Get Content on the Screen
In the preceding chapter, we assembled views to create a complete application. We used Interface
UIView
and how
UIView
is the base component class of UIKit. All other UI elements, such as buttons,
UIView
. Even the class
UIWindow
is a
UIView
, so when we manipulate content on the screen, a lot of what we will be doing is
UIView
class.
The
UIView
class works a lot like the base UI component class in other programming environments.
Each
UIView
defines a region of the screen and has a number of children, or subviews, which are
drawn relative to their parent. Figure
4-2
shows an example layout of
UIView
instances.
UlWindow
GameController View
Portrait Play View
UlLabels
UlLabels
Portrait game Holder View
Coins Controller View
(Coins Controller subviews not shown)
Figure 4-2.
Nested UIView instances