Class GameComponent
An object that can be attached to a Game and have its Update(GameTime) method called when Update(GameTime) is called.
public class GameComponent : IGameComponent, IUpdateable, IDisposable
- Inheritance
-
GameComponent
- Implements
- Derived
- Inherited Members
Constructors
GameComponent(Game)
Create a GameComponent.
public GameComponent(Game game)
Parameters
game
GameThe game that this component will belong to.
Properties
Enabled
Indicates whether GameComponent.Update(GameTime) should be called when Game.Update(GameTime) is called.
public bool Enabled { get; set; }
Property Value
Game
The Game that owns this GameComponent.
public Game Game { get; }
Property Value
UpdateOrder
Indicates the order in which the GameComponent should be updated relative to other GameComponent instances. Lower values are updated first.
public int UpdateOrder { get; set; }
Property Value
Methods
Dispose()
Shuts down the component.
public void Dispose()
Dispose(bool)
Shuts down the component.
protected virtual void Dispose(bool disposing)
Parameters
disposing
bool
~GameComponent()
protected ~GameComponent()
Initialize()
Called when the GameComponent needs to be initialized.
public virtual void Initialize()
OnEnabledChanged(object, EventArgs)
Called when Enabled changed. Raises the EnabledChanged event.
protected virtual void OnEnabledChanged(object sender, EventArgs args)
Parameters
sender
objectThis GameComponent.
args
EventArgsArguments to the EnabledChanged event.
OnUpdateOrderChanged(object, EventArgs)
Called when UpdateOrder changed. Raises the UpdateOrderChanged event.
protected virtual void OnUpdateOrderChanged(object sender, EventArgs args)
Parameters
sender
objectThis GameComponent.
args
EventArgsArguments to the UpdateOrderChanged event.
Update(GameTime)
Update the component.
public virtual void Update(GameTime gameTime)
Parameters
Events
EnabledChanged
Raised when Enabled changed.
public event EventHandler<EventArgs> EnabledChanged
Event Type
UpdateOrderChanged
Raised when UpdateOrder changed.
public event EventHandler<EventArgs> UpdateOrderChanged