XNA Game Components & Services

http://msdn.microsoft.com/en-us/library/bb203873.aspx

XNA
Components & Services to pass values of variables from 1 game component to
another.
http://blog.nuclex-games.com/tutorials/xna/components-and-services/

//
add gamecomponents into the services
Components.Add(mInputManager = new
InputManager(this));
Services.AddService(typeof(InputManager),
mInputManager);
Components.Add(mDrawString = new
DrawString(this));
Services.AddService(typeof(DrawString),
mDrawString);
//
getting the component back out from another component
InputManager input =
(InputManager)Game.Services.GetService(typeof(InputManager));

Leave a Reply

Your email address will not be published. Required fields are marked *