Class DrawableGameComponent
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)
Create a DrawableGameComponent.
public DrawableGameComponent(Game game)
Parameters
game
GameThe 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
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
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
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
GameTimeThe 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
objectThis DrawableGameComponent.
args
EventArgsArguments to the DrawOrderChanged event.
OnVisibleChanged(object, EventArgs)
Called when Visible changed.
protected virtual void OnVisibleChanged(object sender, EventArgs args)
Parameters
sender
objectThis DrawableGameComponent.
args
EventArgsArguments 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
VisibleChanged
Raised when Visible changed.
public event EventHandler<EventArgs> VisibleChanged