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 if Update(GameTime) will be called.

public bool Enabled { get; set; }

Property Value

bool

Game

The Game that owns this GameComponent.

public Game Game { get; }

Property Value

Game

UpdateOrder

The update order of this GameComponent relative to other GameComponent instances.

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()

Initializes the component. Used to load non-graphical resources.

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>