Game Development Reference
In-Depth Information
About Memory:
Memory is a precious resource in an iOS device. Although iPhone 4S
can have up to 64GB, the dynamic memory allocated for your runtime
is much more limited (a few MB only). It is an excellent practice to
destroy an actor as soon as it becomes useless for the rest of the
game. If your actor will be needed later, an advance technique for
performance optimization is recycling. Recycling is covered in
Chapter 7.
To keep score, create two attributes to store the scores of each player.
In the Scene Editor, select the Attributes Inspector window and create a new
Integer attribute by clicking the + sign. Name it P1 Score. Repeat the operations
but name the attribute P2 Score.
In the Scene view, create a new actor and change the following attributes:
Name: Left Winning Zone
Size/Width: 10
Size/Height: 320
Color/Alpha: 0
Physics/Density: 0
Physics/Moveable: Unchecked
As you may have noticed, fixed rotation is left unchecked here. Fixed rotation is
to prevent an actor from spinning around when it collides with another actor. As
this actor will not collide with any other actors, it is unnecessary to check fixed
rotation.
You should end up with the same attributes as Figure 3-1.
 
Search WWH ::




Custom Search