Game Development Reference
In-Depth Information
Putting this all together, here's an example that draws "Hello World" on the screen
in yellow:
IwGxLightingEmissve(true);
IwGxFontSetFont(lpSmallFont);
IwGxFontSetCol(0xFF00FFFF);
IwGxFontSetRect(CIwRect(0, 0,IwGxGetScreenWidth(), 100));
IwGxFontDrawText("Hello World");
Text wrapping and justification
Wondering why we specified a rectangular area for our text rather than just a screen
position? The reason is so that IwGxFont can wrap and justify our text for us.
While Marmalade does allow us to include the line feed character in
our code to force a new line in our text, it does not provide support
for other formatting characters such as tabs or backspace. It is far
better to allow Marmalade to word wrap text for us than to insert
line feeds in our text by hand, because if we change the font size or
the dimension of the rectangular draw area we won't have to change
the text itself in any way.
The default behavior when rendering text is to word wrap whenever a line of text
exceeds the bounds of the rectangular area set with IwGxFontSetRect . We can alter
this behavior using the IwGxFontSetFlags function, which can take a combination
of the following values OR'ed together:
Value Definition
IW_GX_FONT_DEFAULT_F      Uses default font settings.
IW_GX_FONT_NOWRAP_F       Does not wrap text at the edge of the rectangle's
boundary.
IW_GX_FONT_NOWORDWRAP_F   Does not perform full word wrapping on text.
IW_GX_FONT_ONELINE_F      Only renders a single line of text. Rendering stops
when a newline character ( '\n' ) is reached.
IW_GX_FONT_NUMBER_ALIGN_F Forces all numbers to be displayed with the same
width.
IW_GX_FONT_UNDERLINE_F    Draws the text with underlining.
IW_GX_FONT_ITALIC_F       Draws the text in italics.
Search WWH ::




Custom Search