Game Development Reference
In-Depth Information
In this case, you must initialize the sprite with a rect that determines the area the
sprite will occupy. The ccTexParams struct is initialized with the wrap parameters
for the texture coordinates set to GL_REPEAT . Don't worry if that doesn't mean any-
thing to you. These OpenGL parameters are then set on the sprite's texture using the
CCTexture2D method setTexParameters .
The result is a tiled area repeating the same square.png image over and over again.
If you move the sprite, the whole area covered by the repeatRect is moved. You
could use this trick to remove the bottommost background stripe and replace it with a
smaller image that simply repeats. I'll leave that up to you as an exercise.
A Virtual Joypad
Because the iOS devices all use a touchscreen for input and have no buttons, D-pads,
or analog joypads like conventional mobile gaming devices do, you need something
called a virtual joypad . This emulates the behavior of digital or analog thumbsticks by
allowing you to touch the screen where the digipad or thumbstick is displayed and
move your finger over it to control the action on the screen. Buttons are also designated
areas of the touchscreen that you can tap or hold to cause actions on the screen. Figure
7-8 shows a virtual joypad in action.
Figure 7-8 . A skinned analog thumbstick and fire button created with SneakyInput
 
 
Search Nedrilad ::




Custom Search