XNA Creators Club Online
Page 1 of 1 (2 items)
Sort Posts: Previous Next

game service vs game component

Last post 05-04-2008 11:57 AM by Shawn Hargreaves. 1 replies.
  • 05-04-2008 6:40 AM

    game service vs game component

    Hello, I am trying to follow a tutorial and have become a bit confused between the difference of a game component and a game service.  They seem as though they are one in the same.  Can someone explain the differece to in a couple of words. 

    thanks

    Bill

  • 05-04-2008 11:57 AM In reply to

    Re: game service vs game component

    A game component is something that participates in the update/draw game loop. You should use one if your code needs to be updated and/or drawn at regular intervals. Components provide these methods that tie into the application model:
    • Initialize
    • LoadContent
    • Update
    • Draw
    A game service is something that is registered in a centralized place, where it can be discovered by other code. You should use a service if you ever find yourself thinking "hmm, I'm over here, and now I need to get access to the FooManager, but I don't want to strongly tie this code to any particular implementation of FooManager, so I want some decoupled way of looking up if such a manager exists". Services don't imply any particular functionality as to what the object does, though: they're just a way of finding it.

    Often, you will find a piece of code is both a component and a service, if it needs to be updated and drawn and also discovered by other code.
    XNA Framework Developer - blog - homepage
Page 1 of 1 (2 items) Previous Next