Home » Category » Microsoft Game Technologies

Microsoft Game Technologies: XNA sample code problem ?

100| Mon, 31 Dec 2007 20:52:00 GMT| brian_tsim| Comments (2)

Hi all,

i finded xna "XNA Onscreen Keyboard Component" sample in internet(http://www.xnaresources.com/pages.asp?pageid=27). What does the iFontAsciiStart and iFontAsciiEnd mean in function WriteText ()? Please somebody help. Below is the function coding.

public void WriteText(SpriteBatch spriteBatch, string sTextOut, int x, int y, Color colorTint)
{
// Very simple text output method. Uses a mono-spaced font to keep things easy
int iFontX = 0;
int iFontY = 0;
int iFontHeight = 30;
int iFontWidth = 19;
int iFontAsciiStart = 32;
int iFontAsciiEnd = 126;
int iOutChar;
for (int i = 0; i < sTextOut.Length; i++)
{
iOutChar = (int)sTextOutIdea;
if ((iOutChar >= iFontAsciiStart) & (iOutChar <= iFontAsciiEnd))
{
spriteBatch.Draw( t2dFont,
new Rectangle( x + (iFontWidth * i), y, iFontWidth-1, iFontHeight),
new Rectangle( iFontX + ((iOutChar - iFontAsciiStart) * iFontWidth),
iFontY, iFontWidth-1, iFontHeight),
colorTint
);
}
}
}

Best Regrads,

Keywords & Tags: xna, sample, code, microsoft, game

URL: http://msdn.itags.org/microsoft-game/244623/
 
«« Prev - Next »» 2 helpful answers below.

Moved to XNA forum but you should try reposting in the new forums http://creators.xna.com

thezman | Fri, 07 Sep 2007 16:33:00 GMT |

brian_tsim wrote:
What does the iFontAsciiStart and iFontAsciiEnd mean in function WriteText ()?

This is ensuring that the character being rendered is one that can actually be rendered. Only certain characters can be rendered - A-Z, 1-0, etc. Special characters cannot be rendered with the code.

jimperry | Fri, 07 Sep 2007 16:34:00 GMT |

Microsoft Game Technologies Hot Answers

Microsoft Game Technologies New questions

Microsoft Game Technologies Related Categories