Gondwana Game Engine
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop, mobile, and web platforms using SkiaSharp for graphics and NAudio for sound.
Loading...
Searching...
No Matches
Gondwana.Drawing.Sprites.Sprite Class Reference

Represents a movable visual element on a scene layer that can be positioned, animated, and rendered with collision detection. Sprites support alignment, positioning, animation, and can be managed through the SpriteManager. More...

Inheritance diagram for Gondwana.Drawing.Sprites.Sprite:
Gondwana.Drawing.Tile Gondwana.Collisions.ICollisionMovableEntity Gondwana.Drawing.IDrawable Gondwana.Collisions.ICollisionEntity Gondwana.Collisions.ICollisionEntity

Public Member Functions

Vector2 GetPosition ()
 Gets the current position of the sprite in scene layer coordinates.
void SetPosition (Vector2 pos)
 Sets the position of the sprite in scene layer coordinates and updates the display.
void TranslateWorldPx (int dx, int dy)
 Applies a world-pixel translation. Used by collision resolution.
override void Dispose ()
 Releases all resources used by the sprite and removes it from the sprite manager.
void ResizeTo (Size targetSize, float durationSeconds)
 Smoothly resize the sprite to an absolute pixel size over the given duration (seconds).
void ScaleBy (float factor, float durationSeconds)
 Scale to a factor relative to current RenderSize over the given duration (seconds). factor > 1 grows; factor < 1 shrinks.
void CancelResize ()
 Cancel any in-progress resize.
Public Member Functions inherited from Gondwana.Drawing.Tile
virtual RectangleF GetDrawLocationScreen (View view)
 Converts the tile's world location to screen coordinates based on the specified view.
virtual RectangleF GetCollisionAreaScreen (View view)
 Converts the tile's collision area from world coordinates to screen coordinates.
virtual void Draw (BackbufferBase backbuffer, RectangleF destRectScreen)
 Renders the tile to the specified backbuffer at the given screen location.
int CompareTo (Tile? tile)
 Compares this tile to another tile for sorting purposes. Fixed-position tiles are rendered first, followed by tiles sorted by Y-coordinate, Z-order, and X-coordinate.

Properties

MovementSpace PositionSpace [get]
 Gets the movement space used by this sprite.
MovementController Movement [get]
 Gets the movement controller for this sprite.
HorizontalAlignment HorizAlign [get, set]
 Gets or sets the horizontal alignment of the sprite relative to its scene layer coordinates.
VerticalAlignment VertAlign [get, set]
 Gets or sets the vertical alignment of the sprite relative to its scene layer coordinates.
int NudgeX [get, set]
 Gets or sets the horizontal pixel offset (nudge) to apply to the sprite's position.
int NudgeY [get, set]
 Gets or sets the vertical pixel offset (nudge) to apply to the sprite's position.
Size RenderSize [get, set]
 Gets or sets the size at which the sprite will be rendered.
override Rectangle DrawLocationWorld [get]
 Gets the world-space pixel rectangle where the sprite will be drawn, taking into account alignment, size, and nudge offsets.
override bool IsPositionFixed [get]
 Gets a value indicating whether the sprite's position is fixed. Always returns false for sprites.
override PointF SceneLayerCoordinates [get]
 Gets the scene layer coordinates of the sprite.
override SceneLayer SceneLayer [get]
 Gets the scene layer that this sprite is attached to.
virtual new int ZOrder [get, set]
 Gets or sets the Z-order (depth) of the sprite for rendering. Higher values are drawn on top. Minimum value is 1.
Properties inherited from Gondwana.Drawing.Tile
static List< TileTilesAnimating = new() [get]
 Gets the collection of all tiles that are currently animating in the scene. Used to track and update animated tiles during the render cycle.
bool IsPositionFixed [get]
 Gets a value indicating whether the tile's position is fixed in screen space (e.g., UI elements) or moves with the world (e.g., game objects).
Rectangle DrawLocationWorld [get]
 Gets the tile's draw location in world coordinates as a rectangle. This represents the area occupied by the tile in the game world.
PointF SceneLayerCoordinates [get]
 Gets the tile's position within its scene layer using the layer's coordinate system.
SceneLayer SceneLayer [get]
 Gets the scene layer that contains this tile.
Guid Id = Guid.NewGuid() [get]
 Gets the unique identifier for this tile instance.
string? Nickname [get, set]
 Gets or sets an optional friendly name for the tile, useful for debugging and identification.
virtual bool Visible [get, set]
 Gets or sets a value indicating whether the tile is visible and should be rendered. Setting this property triggers a refresh of the tile's screen area.
virtual int ZOrder [get, set]
 Gets or sets the Z-order (depth) of the tile for rendering priority. Higher values are drawn later (on top of lower values). Setting this property triggers a refresh of the tile's screen area.
virtual Overhang OverhangPixels [get]
 Gets the overhang dimensions (in pixels) that extend beyond the tile's primary area. This is typically used for tiles with visual elements that exceed their logical boundaries.
virtual Frame CurrentFrame [get, set]
 Gets or sets the current frame being displayed for this tile. Setting this property triggers a refresh of both the old and new tile areas to handle size changes.
virtual Animator TileAnimator [get]
 Gets the animator responsible for managing frame transitions and animation sequences for this tile.
virtual bool PauseAnimation [get, set]
 Gets or sets a value indicating whether the tile's animation is currently paused.
virtual ? ICollider Collider [get]
 Gets the collider used for collision detection with this tile. Returns null if the tile has no collision detection.
virtual Rectangle CollisionArea [get]
 Gets the effective collision area of the tile in world coordinates, incorporating any adjustments specified by AdjustCollisionArea.
virtual bool EnableFog [get, set]
 Gets or sets a value indicating whether fog of war rendering is enabled for this tile. Setting this property triggers a refresh of the tile's screen area.
virtual Point[] OutlinePointsWorld [get]
 Used to determine polygonal area when drawing grid lines or fog. Override this property in a derived class to define custom areas for these effects.
virtual CollisionDetectionAdjustment AdjustCollisionArea = CollisionDetectionAdjustment.None [get, set]
 Gets or sets the collision area adjustment values that modify the tile's collision boundaries. Use this to fine-tune the collision detection area relative to the tile's visual bounds.
bool CollisionsEnabled [get, set]
 Gets or sets a value indicating whether collision detection is enabled for this tile. When set to true, the tile's collider is registered with the scene layer's collision system. When set to false, the collider is unregistered and collisions will not be detected.
TypedValueBag ValueBag = new() [get]
 Gets the value bag for storing arbitrary typed values associated with this tile. Useful for attaching custom game-specific data without subclassing.

Events

Action< SpriteMovedEventArgs >? SpriteMoved
 Occurs when the sprite has moved to a new position on the scene layer.
Action< Sprite >? Disposing
 Occurs when the sprite is being disposed.

Additional Inherited Members

Protected Attributes inherited from Gondwana.Drawing.Tile
bool pauseAnimation
ICollider_collider

Detailed Description

Represents a movable visual element on a scene layer that can be positioned, animated, and rendered with collision detection. Sprites support alignment, positioning, animation, and can be managed through the SpriteManager.

Member Function Documentation

◆ CancelResize()

void Gondwana.Drawing.Sprites.Sprite.CancelResize ( )

Cancel any in-progress resize.

◆ Dispose()

override void Gondwana.Drawing.Sprites.Sprite.Dispose ( )
virtual

Releases all resources used by the sprite and removes it from the sprite manager.

Reimplemented from Gondwana.Drawing.Tile.

◆ GetPosition()

Vector2 Gondwana.Drawing.Sprites.Sprite.GetPosition ( )

Gets the current position of the sprite in scene layer coordinates.

Returns
A Vector2 representing the sprite's position.

◆ ResizeTo()

void Gondwana.Drawing.Sprites.Sprite.ResizeTo ( Size targetSize,
float durationSeconds )

Smoothly resize the sprite to an absolute pixel size over the given duration (seconds).

Parameters
targetSizeThe target size in pixels to resize to.
durationSecondsThe duration of the resize animation in seconds.

◆ ScaleBy()

void Gondwana.Drawing.Sprites.Sprite.ScaleBy ( float factor,
float durationSeconds )

Scale to a factor relative to current RenderSize over the given duration (seconds). factor > 1 grows; factor < 1 shrinks.

Parameters
factorThe scaling factor. Values greater than 1 grow the sprite, values less than 1 shrink it.
durationSecondsThe duration of the scaling animation in seconds.

◆ SetPosition()

void Gondwana.Drawing.Sprites.Sprite.SetPosition ( Vector2 pos)

Sets the position of the sprite in scene layer coordinates and updates the display.

Parameters
posThe new position for the sprite.

◆ TranslateWorldPx()

void Gondwana.Drawing.Sprites.Sprite.TranslateWorldPx ( int dx,
int dy )

Applies a world-pixel translation. Used by collision resolution.

Parameters
dxThe horizontal pixel offset to apply.
dyThe vertical pixel offset to apply.

Implements Gondwana.Collisions.ICollisionMovableEntity.

Property Documentation

◆ DrawLocationWorld

override Rectangle Gondwana.Drawing.Sprites.Sprite.DrawLocationWorld
get

Gets the world-space pixel rectangle where the sprite will be drawn, taking into account alignment, size, and nudge offsets.

◆ HorizAlign

HorizontalAlignment Gondwana.Drawing.Sprites.Sprite.HorizAlign
getset

Gets or sets the horizontal alignment of the sprite relative to its scene layer coordinates.

◆ IsPositionFixed

override bool Gondwana.Drawing.Sprites.Sprite.IsPositionFixed
get

Gets a value indicating whether the sprite's position is fixed. Always returns false for sprites.

◆ Movement

MovementController Gondwana.Drawing.Sprites.Sprite.Movement
get

Gets the movement controller for this sprite.

◆ NudgeX

int Gondwana.Drawing.Sprites.Sprite.NudgeX
getset

Gets or sets the horizontal pixel offset (nudge) to apply to the sprite's position.

◆ NudgeY

int Gondwana.Drawing.Sprites.Sprite.NudgeY
getset

Gets or sets the vertical pixel offset (nudge) to apply to the sprite's position.

◆ PositionSpace

MovementSpace Gondwana.Drawing.Sprites.Sprite.PositionSpace
get

Gets the movement space used by this sprite.

◆ RenderSize

Size Gondwana.Drawing.Sprites.Sprite.RenderSize
getset

Gets or sets the size at which the sprite will be rendered.

◆ SceneLayer

override SceneLayer Gondwana.Drawing.Sprites.Sprite.SceneLayer
get

Gets the scene layer that this sprite is attached to.

◆ SceneLayerCoordinates

override PointF Gondwana.Drawing.Sprites.Sprite.SceneLayerCoordinates
get

Gets the scene layer coordinates of the sprite.

◆ VertAlign

VerticalAlignment Gondwana.Drawing.Sprites.Sprite.VertAlign
getset

Gets or sets the vertical alignment of the sprite relative to its scene layer coordinates.

◆ ZOrder

virtual new int Gondwana.Drawing.Sprites.Sprite.ZOrder
getset

Gets or sets the Z-order (depth) of the sprite for rendering. Higher values are drawn on top. Minimum value is 1.

Implements Gondwana.Drawing.IDrawable.

Event Documentation

◆ Disposing

Action<Sprite>? Gondwana.Drawing.Sprites.Sprite.Disposing

Occurs when the sprite is being disposed.

◆ SpriteMoved

Action<SpriteMovedEventArgs>? Gondwana.Drawing.Sprites.Sprite.SpriteMoved

Occurs when the sprite has moved to a new position on the scene layer.