Game Development Reference
In-Depth Information
Marmalade also ships with a whitepaper that covers some of the things to be
careful about when developing a game destined to run on more than one device
specification. You can find it in the Marmalade documentation at Whitepapers |
Device Independent Code .
Dealing with different screen resolutions
Probably the most immediately notable difference between different devices will be
the screen resolution. Taking iOS as an example, you may find yourself having to
support screen resolutions ranging from 320 x 480 at the low end through the two
different iPhone Retina screen resolutions (640 x 960 and 640 x 1136) and iPad at 1024
x 768, right up to the frankly crazy resolution of 2048 x 1536 of the most recent iPad
(you'll be hard pressed to find a PC monitor capable of displaying that resolution!).
We've already touched on this subject in Chapter 6 , Implementing Fonts, User Interfaces,
and Localization , when we discussed the best way of implementing a user interface.
We should never hardcode our game to work at a fixed screen resolution as it will be
much harder to port it across to other screen resolutions later.
Instead, we should query Marmalade for the screen dimensions and then use these
values to position and size everything we want to draw, whether that be through
using percentages of the screen size, by clamping objects to the edges of the screen,
or indeed some other method of your own choosing. We can find the screen width
and height as follows:
uint32 lScreenWidth = IwGxGetScreenWidth();
uint32 lScreenHeight = IwGxGetScreenHeight();
These functions will also automatically take care of device orientation. The returned
values will change when the player rotates the device, unless we have disabled this
functionality using the DispFixRot ICF file setting (more on this setting shortly).
Using different resources for different screen
resolutions
Using the screen dimensions to position and size the elements we wish to draw
works well, but it does lead to a further problem. We may find that any images used
to render items on screen start to look blurry or blocky if they have to be scaled up in
size too much.
Similarly, fonts that work well at a low resolution may become impossible to read
because they are too small when used on a higher-resolution device. While we could
just apply a scale to the font when rendering, a more aesthetically pleasing solution
is to use a different version of the font created at a bigger point size.
 
Search WWH ::




Custom Search