Microsoft Game Technologies: XNA sample code problem ?

  • brian_tsim / 100 / Sun, 31 Jan 2010 04:46:00 GMT / 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:

    xna, sample, code, microsoft, game

  • http://msdn.itags.org/microsoft-game/244623/«« Last Thread - Next Thread »»
    1. 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 |

    2. 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 Questions

    • XNA is really great

      Hello! My first post on the forum. My name is Phantasy, I like fantasy so that is why. I am sure XNA...

      By phantasy

    • XNA Podcast

      XBL Radio.com has put out their roundtable on XNA with myself and a couple of developers. Check it o...

      By jimperry

    • . TRIDEX .VB.NET XNA update#8 Bounding Box,Sphere,...

      hi Guys another update with the games component for redering bounding box,Spheres , line, the code e...

      By tridex

    • 3ds Max scene setup

      I was wondering, is there a proper way to setup an object in max for export as .fbx to xna?For examp...

      By dchin

    • XNA Quake BSP class code

      I released the code of my bsp class its not fully completed but the hard work is done. The rendering...

      By perpixel, 1 Comments

    • XNA Starting

      Well, I got XNA yesterday and i have been trying to figure out how to use it all day. I have used th...

      By daytonadav, 4 Comments

    • XNA GSE Help Files!!!?

      Dear,I Did Installed VC# Express And XNA GSE.Where Can I Found The XNA Tutorials And Help Files?...

      By hassanayoub, 3 Comments

    • XNA GSE - Vista installation

      Hello all,I'm running the latest Vista Ultimate (MSDN) version on my machine. For some reason I can'...

      By ericvanfeggelen, 4 Comments

    • XNA Game Studio Express - 8/30/06 ?

      I "Hear" the XNA Game Studio Express will be available 8/30/06 - (?)Is there a Specific Si...

      By echsbachs, 4 Comments