XNA Reusable FPS Counter and SpriteFonts
Friday, June 08 2007 - gse, xna
Shawn Hargreaves has just posted a small code Game Component that will display the Framerate for you application using the spritefont. One of the good things about this is that Shawn shows you a simple method of reducing the size of the font files by only using the characters that you need.
Here is the link to the Post...
Going over the code I have decided to change the framerate component that shawn posted about and also change the one I was using in my Game Framework project. What I have now done is added the SpriteFont system that Shawn Posts about to my code. Now the Game Component that I have will allow you to decide on how the FPS is displayed at the time of construction, you now have the option of the Debug Window, the Windows Title and also the Game screen.
One thing I did notice it that the current FPS that is used will display in the order at which you create the game components, what you can do is change the draw order for the FPS Component so that it is draw last, to do this once you have created the game components object and before adding it to the collection change the draw order property to a higher number. This Draw order property takes an int value and the components are drawn from the lowest number first and the highest last. So setting the value to 100 will make sure that the framerate component is always drawn last.
