Class Sprite
Represents a sprite element in a 2D or 3D environment.
Inherited Members
Namespace: Genesis.Core.GameElements
Assembly: Genesis.dll
Syntax
public class Sprite : GameElement
Constructors
Sprite(string, Vec3, Vec3, SpriteSheet, int, int)
Initializes a new instance of the Sprite class.
Declaration
public Sprite(string name, Vec3 location, Vec3 size, SpriteSheet spriteSheet, int col, int row)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the sprite. |
Vec3 | location | The location of the sprite. |
Vec3 | size | The size of the sprite. |
SpriteSheet | spriteSheet | The sprite sheet from which this sprite is sourced. |
int | col | The column index of the sprite in the sprite sheet. |
int | row | The row index of the sprite in the sprite sheet. |
Sprite(string, Vec3, Vec3, Texture)
Initializes a new instance of the Sprite class with specified name, location, size, and texture.
Declaration
public Sprite(string name, Vec3 location, Vec3 size, Texture texture)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the sprite. |
Vec3 | location | The initial location of the sprite. |
Vec3 | size | The size of the sprite. |
Texture | texture | The texture for the sprite. |
Properties
Color
Gets or sets the color of the sprite.
Declaration
public Color Color { get; set; }
Property Value
Type | Description |
---|---|
Color |
OcclusionCulling
Gets or sets a value indicating whether occlusion culling is enabled for the sprite.
Declaration
public bool OcclusionCulling { get; set; }
Property Value
Type | Description |
---|---|
bool |
TexCoords
Gets or sets the texture coordinates of the sprite.
Declaration
public TexCoords TexCoords { get; set; }
Property Value
Type | Description |
---|---|
TexCoords |
Texture
Gets or sets the texture of the sprite.
Declaration
public Texture Texture { get; set; }
Property Value
Type | Description |
---|---|
Texture |
Methods
CalculateVerticies()
Calculates the vertex coordinates of the sprite.
Declaration
public float[] CalculateVerticies()
Returns
Type | Description |
---|---|
float[] | An array containing the vertex coordinates of the sprite. |
GetBounds2D()
Gets the 2D bounds of the sprite.
Declaration
public Rect GetBounds2D()
Returns
Type | Description |
---|---|
Rect | A rectangular region representing the 2D bounds of the sprite. |
GetCenterLocation()
Gets the center location of the sprite.
Declaration
public Vec3 GetCenterLocation()
Returns
Type | Description |
---|---|
Vec3 | The center location of the sprite. |
Init(Game, IRenderDevice)
Initializes the sprite element.
Declaration
public override void Init(Game game, IRenderDevice renderDevice)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
IRenderDevice | renderDevice | The render device used for rendering. |
Overrides
OnDestroy(Game)
Handles cleanup and resource disposal when the sprite is destroyed.
Declaration
public override void OnDestroy(Game game)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
Overrides
OnRender(Game, IRenderDevice)
Renders the sprite element.
Declaration
public override void OnRender(Game game, IRenderDevice renderDevice)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
IRenderDevice | renderDevice | The render device used for rendering. |