DeadlyEvilRyu

I need help displaying text in my game I have everything in the game (sprite movements, game rules, and other stuff like that). I just don't know how to go about displaying text I tried looking for tutorials, but they were kind of confusing.

Thanks in advance.



Re: Game Technologies: General I need help displaying text in an XNA game

George Clingerman

Well, there isn't any native or built in text support in XNA. So basically when you want to draw text, you are just drawing another sprite.

Typically, what you do is create a single image with your font in it. So you draw out an A, B, C, D, etc. (all of the letters, number, symbols, etc) that you want to draw.

Then in your code you have to write functions that will draw those for you. So when you want to draw the letter "A", your code has to call the SpriteBatch.Draw method, pass in the Alphabet texture you made, position the sprite where you want it to be and cut just the "A" out of your texture.

So you'll want to write code that "knows" where to cut out each of your letters, symbols, etc from out of your Alphabet texture. Then you can write methods that just take a block of text and a position to display the text and it will just do all of the displaying for the text.

It seems like a lot of work and it is the first time you have to do it. Once you have the methods and classes to handle it though, you can reuse them again and again in future projects.

There are a couple of people that have already written font classes, but since you haven't done it yet, I would recommend playing with it first to make yourself familiar with the concept before using one of their classes.

Also, there is a Font object on it's way from Microsoft so hopefully that arrives soon, but until then, you have to just draw each letter like I described.

Hope that helps!





Re: Game Technologies: General I need help displaying text in an XNA game

john armitage

Darn. I thought that in that Channel 9 video covering the launch party, they said the font object was available now.




Re: Game Technologies: General I need help displaying text in an XNA game

George Clingerman

It's still being worked on and hasn't been released yet. There's a lot of new content like the Font component that they are just putting the polish on and we should be getting soon.





Re: Game Technologies: General I need help displaying text in an XNA game

DeadlyEvilRyu

Ok I think I sort of got if I have any questions I will post them here.