Category Archives: Mobile Device

How to Display Text in your XNA Windows Phone 7 game

First thing you need to do is add a SpriteFont object to your code.

Done like this: SpriteFont myFont (or whatever name you want to give it).

SpriteFont mySpriteFont

Add SpriteFont

Next you need an actual font you can load. For that you go to your solution explorer and right click your content project. Select add -> new item -> SpriteFont.

Add new item

Add SpriteFont to content project

Maybe you should select a better name, that the default one. But it doesn’t really matter much.

Select SpriteFont

Add SpriteFont

You can edit how your font looks like in the .spritefont file. It is a XML like format. Most stuff you find in there should be pretty much self-explanatory. At the bottom you find tags specifying a character region. Please note, that not all fonts can display all characters. If you happen onto a bug resulting from some character display problem or exception, have a look here, if your font can display all your characters. The rest describes size, text decoration and stuff.

spritefont file

The font description

For this post, I leave everything like it is and go on to actually displaying something on the phone.

First we need to load our SpriteFont1 in the ContentLoad()-method of our game class.

myFont = Content.Load("SpriteFont1")

All we have to do is display some text now.

We go to the Draw-method and beginn the spriteBatch draw with SpriteBatch.Begin().  The spriteBatch-Class offers us a DrawString-mehtod we use to display text. It first parameter is our SpriteFont. The secont the String you wish to display. This could of course come out of some Sting variable. The third is the position of the text on the screen and the last one, the color in the text is drawn in. We complete this with a spriteBatch.End() in the next line.

And see the result here: I made the Font bigger and red for this example. The size is controlled in the .spritefont file, the color can be selected in the DrawString-method.

Text on WP7 emulator

What Windows Phone 7 (WP7) Device (mobile phone) to buy?

Currently i am wondering about buying a new Phone.

As an enthusiastic game programmer with some years of experience with XNA and C# my choice would be WP7.

I could now spend some time discussing the pros and cons of WP7 vs. Android vs. iOS, but i won’t. The short answer is, that iPhone is too expensive and i do  not know enough about Android programming. That might change in the future but right now i feel that i simply want a WP7 device. No hard reasons for that, just curiosity and the great price of course.

So after browsing some friendly electronic discounter around the corner i narrowed it down to two possibilities.

The Samsung Omnia 7 and the LG Optimus 7.

The cheapest WP7 phone at the moment is the HTC 7 Trophy. You can get it a low as $238. But this phone is not available worldwide. It seems to be aimed at the european market. So if you can get it for such great price where you live, it is an alternative. It is just a WP7 phone, that meats all requirements and does nothing really wrong, but at the same time nothing really amazing.

Price:

Please note, that these are not the amazon.com prices but the cheapest offer i found around.
Samsung Omnia 7: 318$
LG Optimus: 253$
The difference in price is about 65$ in favor of the LG Optimus 7. So one point to the Optimus 7.

Memory:

The Omnia comes with 8GB or 16GB. I am talking about the 8GB version here.
Samsung Omnia 7: 8GB
LG Optimus: 14GB
The next point for the Optimus 7.

Display:

Okay, here wins the Samsung Omnia 7 Super AMOLED display, no arguments: Point to Samsung.
I could write more about how good this display is, but let me say just this: If the display is the most important part for you -> Buy the Omnia 7.

Size:

138g and 122,6mm height for Samasung.
158g and 125mm height for the LG.
I carry my phone around in my pocket so this is a point for the Samsung Omnia 7.

Special features:

The LG is to this time the only WP7 phone that has augmentet reality features implementet. So if you like this stuff it is a pretty good reason to get the Optimus 7.
The Omnia7 is lacking here. It has got its really great display, and a slightly better camera that the LG (at least that is what tests show).
As all of this is a question of personal preferences i will not award a point. You should decide for yourself what is important to you in a mobile phone.

Conclusion:

It’s a draw. Well of course i knew it would end like this. If one of the phones would be the obviously winner there would be not need for this post.

And now? Well in the end everybody have to decide for oneself but i would certainly appreciate your input on this. Do you own a WP7 phone? Are you planning to buy one? Leave your input in the comments.
Currently i am leaning towards the Omnia 7.

%d bloggers like this: