• Advertisement
Sign in to follow this  

[.net] [XNA] Services and Components

This topic is 3771 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This was asked before, but not answered. What's the purpose of Game Services if I can just use Game Components?

Share this post


Link to post
Share on other sites
Advertisement
google "xna + game services":
http://blogs.msdn.com/mitchw/archive/2006/09/06/742955.aspx

Share this post


Link to post
Share on other sites

You will find that a game service will help a lot, with it you can define it once and use it inside the game components. This way a value will be carried across and you do not have to pass the full component across, just the interface for the service.

Share this post


Link to post
Share on other sites
Think about Services as a unique instance of a game component. Something in between a static class and an instanced class. The class can be instanced, but it is guaranteed to only exist once in the Services list. This is useful for classes that maintain global statistics or do something globally.

One example may be a class that counts polygons being rendered. As you create a new class that draws some polygons, you can grab a reference to the polygon counter class and add the number of polygons you are rendering to it. You obviously only want one of these, but you don't want to make it static because you only want your game components to have access (something without the Game.Services reference cannot access the object).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement