Table of Contents

Class DrawableGameComponent

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

A drawable object that, when added to the Game.Components collection of a Game instance, will have it's Draw(GameTime) method called when Game.Draw(GameTime) is called.

public class DrawableGameComponent : GameComponent, IGameComponent, IUpdateable, IDisposable, IDrawable
Inheritance
DrawableGameComponent
Implements
Inherited Members

Remarks

This inherits from GameComponent so it's Update(GameTime) method will also be called when Game.Update(GameTime) is called.

Constructors

DrawableGameComponent(Game)

public DrawableGameComponent(Game game)

Parameters

game Game

The game that this component will belong to.

Properties

DrawOrder

Gets the order in which this component should be drawn, relative to other components that are in the same GameComponentCollection.

public int DrawOrder { get; set; }

Property Value

int

Remarks

This value can be any integer. Components in the GameComponentCollection are drawn in ascending order based on their DrawOrder.

GraphicsDevice

Get the GraphicsDevice that this DrawableGameComponent uses for drawing.

public GraphicsDevice GraphicsDevice { get; }

Property Value

GraphicsDevice

Visible

Gets or Sets a value that indicates whether the Draw(GameTime) method of this component should be called.

public bool Visible { get; set; }

Property Value

bool

Methods

Dispose(bool)

Shuts down the component.

protected override void Dispose(bool disposing)

Parameters

disposing bool

Draw(GameTime)

Draw this component.

public virtual void Draw(GameTime gameTime)

Parameters

gameTime GameTime

The time elapsed since the last call to Draw(GameTime).

Initialize()

Called when the GameComponent needs to be initialized.

public override void Initialize()

LoadContent()

Load graphical resources needed by this component.

protected virtual void LoadContent()

OnDrawOrderChanged(object, EventArgs)

Called when DrawOrder changed.

protected virtual void OnDrawOrderChanged(object sender, EventArgs args)

Parameters

sender object

This DrawableGameComponent.

args EventArgs

Arguments to the DrawOrderChanged event.

OnVisibleChanged(object, EventArgs)

Called when Visible changed.

protected virtual void OnVisibleChanged(object sender, EventArgs args)

Parameters

sender object

This DrawableGameComponent.

args EventArgs

Arguments to the VisibleChanged event.

UnloadContent()

Unload graphical resources needed by this component.

protected virtual void UnloadContent()

Events

DrawOrderChanged

Raised when DrawOrder changed.

public event EventHandler<EventArgs> DrawOrderChanged

Event Type

EventHandler<EventArgs>

VisibleChanged

Raised when Visible changed.

public event EventHandler<EventArgs> VisibleChanged

Event Type

EventHandler<EventArgs>