Back to monogame.net
Show / Hide Table of Contents

Class GameComponent

An object that can be attached to a Game and have its Update(GameTime) method called when Update(GameTime) is called.

Inheritance
Object
GameComponent
DrawableGameComponent
Implements
IGameComponent
IUpdateable
IDisposable
Namespace: Microsoft.Xna.Framework
Assembly: MonoGame.Framework.dll
Syntax
public class GameComponent : object, IGameComponent, IUpdateable

Constructors

GameComponent(Game)

Create a GameComponent.

Declaration
public GameComponent(Game game)
Parameters
Type Name Description
Game game

The game that this component will belong to.

Properties

Enabled

Declaration
public bool Enabled { get; set; }
Property Value
Type Description
Boolean

Game

The Game that owns this GameComponent.

Declaration
public Game Game { get; }
Property Value
Type Description
Game

UpdateOrder

Declaration
public int UpdateOrder { get; set; }
Property Value
Type Description
Int32

Methods

Dispose()

Shuts down the component.

Declaration
public void Dispose()

Dispose(Boolean)

Shuts down the component.

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
Boolean disposing

Finalize()

Declaration
protected void Finalize()

Initialize()

Declaration
public virtual void Initialize()

OnEnabledChanged(Object, EventArgs)

Called when Enabled changed. Raises the EnabledChanged event.

Declaration
protected virtual void OnEnabledChanged(object sender, EventArgs args)
Parameters
Type Name Description
Object sender

This GameComponent.

EventArgs args

Arguments to the EnabledChanged event.

OnUpdateOrderChanged(Object, EventArgs)

Called when UpdateOrder changed. Raises the UpdateOrderChanged event.

Declaration
protected virtual void OnUpdateOrderChanged(object sender, EventArgs args)
Parameters
Type Name Description
Object sender

This GameComponent.

EventArgs args

Arguments to the UpdateOrderChanged event.

Update(GameTime)

Update the component.

Declaration
public virtual void Update(GameTime gameTime)
Parameters
Type Name Description
GameTime gameTime

GameTime of the Game.

Events

EnabledChanged

Declaration
public event EventHandler<EventArgs> EnabledChanged
Event Type
Type Description
EventHandler<EventArgs>

UpdateOrderChanged

Declaration
public event EventHandler<EventArgs> UpdateOrderChanged
Event Type
Type Description
EventHandler<EventArgs>

Implements

IGameComponent
IUpdateable
IDisposable
In This Article
Back to top

© 2012 Microsoft Corporation. All rights reserved.

© The MonoGame Team.