Game Development Reference
In-Depth Information
Figure 5-2. Replica Island on the Nexus One (top) and the HTC Hero (bottom)
The Nexus One displays a bit more on the x axis. However, everything is identical on the y axis.
What did the creator of Replica Island do in this case?
Coping with Different Aspect Ratios
Replica Island serves as a very useful example of the aspect ratio problem. The game was
originally designed to fit on a 480×320-pixel screen, including all “the sprites,� such as the robot
and the doctor, the tiles of “the world,� and the UI elements (the buttons at the bottom left and
the status info at the top of the screen). When the game is rendered on a Hero, each pixel in the
sprite bitmaps maps to exactly one pixel on the screen. On a Nexus One, everything is scaled
up while rendering, so one pixel of a sprite actually takes up 1.5 pixels on the screen. In other
words, a 32×32-pixel sprite will be 48×48 pixels on the screen. This scaling factor is easily
calculated using the following equations:
scaling factor (on x-axis) = screen width in pixels / target width in pixels
scaling factor (on y-axis) = screen height in pixels / target height in pixels
 
Search WWH ::




Custom Search