Table of Contents

Class GameComponent

Namespace
Microsoft.Xna.Framework
Assembly
MonoGame.Framework.dll

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 Game

The 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

bool

Game

The Game that owns this GameComponent.

public Game Game { get; }

Property Value

Game

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

int

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 object

This GameComponent.

args EventArgs

Arguments 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 object

This GameComponent.

args EventArgs

Arguments to the UpdateOrderChanged event.

Update(GameTime)

Update the component.

public virtual void Update(GameTime gameTime)

Parameters

gameTime GameTime

GameTime of the Game.

Events

EnabledChanged

Raised when Enabled changed.

public event EventHandler<EventArgs> EnabledChanged

Event Type

EventHandler<EventArgs>

UpdateOrderChanged

Raised when UpdateOrder changed.

public event EventHandler<EventArgs> UpdateOrderChanged

Event Type

EventHandler<EventArgs>