It's a Control Thing

Sample demonstrating how to draw controller images within text at runtime

It's a Control Thing

automatically drawing controller images within text

ItsAControlThing This is a little project I put together because I was getting frustrated trying to place controller images inside of my lines of text. It's a pain to try and get everything lined up when you're trying to say "Press A to Start" where "A" is the actual image of the button. So in an effort to ease my pain, I wrote some code to do that all for me. Now when I want to put a button image inside of my text, I can just write it like "Press [A] to Start." and the [A] will get automatically replaced by the "A" button image.

The Controller images were provided by Microsoft and you can download them and the spriteFont I'm using for them in this project from the Creator's website here.

The code isn't perfect and it's designed to work best with the "Pescadero" font, size 40 and bold. This is a font provided by Microsoft in their Free Font pack designed for re-distribution by game developers which you can download here. The code still works with other fonts, but the smaller the font size, the more the Y offset is wrong for the controller images.

The main Game1.cs file has some examples of how you can use it (you can see the end result of those samples at the left). I'm going to be using this to help get my projects up and running and maybe you might have a use for it as well.

Technorati Tags: