As noted before, you should derive your class from DrawableGameComponent
. Then you should implement
public override void Update(GameTime gameTime)
{
// TODO: Add your update code here
base.Update(gameTime);
}
public override void Draw(GameTime gameTime)
{
// TODO: Add your update code here
base.Draw(gameTime);
}
It's important to create your DrawableGameComponent
in its container's (typically your Game1
class) constructor and add to Game.Components
in the same place, otherwise your components methods might not get called correctly.
If you manage your components this way, Initialize
, Update
and Draw
will be called automatically by the framework.
The same goes for GameComponent
s, but obviously without the Draw
method.