Class Component
Represents the base class for all behaviors attached to a GameObject.
public class Component : IDisposable
- Inheritance
-
Component
- Implements
- Derived
- Inherited Members
Remarks
Inherit from this class to create custom logic, rendering, or physics behaviors. Components must be attached to a GameObject to function.
Properties
GameObject
Gets the GameObject that owns this component.
public GameObject GameObject { get; }
Property Value
IsActive
Gets or sets whether this component is active.
If false, Update() and Draw(SpriteBatch) will not be called.
public bool IsActive { get; set; }
Property Value
Position
Gets the world position of the parent GameObject.
public Vector2 Position { get; }
Property Value
- Vector2
Scene
Gets the Scene that the parent GameObject belongs to.
public Scene Scene { get; }
Property Value
ShouldDestroy
Gets whether this component is marked for destruction at the end of the frame.
public bool ShouldDestroy { get; }
Property Value
Methods
Destroy()
Marks this component to be removed from its GameObject at the end of the current frame.
public void Destroy()
Dispose()
Releases unmanaged resources used by the component.
public virtual void Dispose()
Draw(SpriteBatch)
Called once per frame to render the component.
protected virtual void Draw(SpriteBatch spriteBatch)
Parameters
spriteBatchSpriteBatchMicrosoft.Xna.Framework.Graphics.SpriteBatch
Initialize()
Called when the component is first initialized.
protected virtual void Initialize()
Remarks
Override this to set up initial state.
InternalDraw(SpriteBatch)
public void InternalDraw(SpriteBatch spriteBatch)
Parameters
spriteBatchSpriteBatch
InternalInitialize()
public void InternalInitialize()
InternalLoadContent()
public void InternalLoadContent()
InternalUpdate()
public void InternalUpdate()
LoadContent()
Called when content needs to be loaded.
protected virtual void LoadContent()
Remarks
Override this to load textures, sounds, or other resources.
Update()
Called once per frame to update game logic.
protected virtual void Update()