Gondwana Game Engine Development (master) - 2.6.1
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 and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
Gondwana.Drawing.Sprites.Sprite Class Reference

Represents a movable visual element on a scene layer. More...

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

Public Member Functions

Vector2 GetPosition ()
 Gets the sprite position in scene-layer grid coordinates.
void SetPosition (Vector2 pos)
 Sets the sprite position in scene-layer grid coordinates and invalidates its old and new bounds.
RectangleF GetVisualBoundsScreen (View view)
 Gets the axis-aligned screen-pixel bounds enclosing the rotated sprite.
override void Draw (BackbufferBase backbuffer, RectangleF destRectScreen)
 Draws the current content into the backbuffer at the supplied screen-pixel bounds.
Parameters
backbufferThe backbuffer receiving the drawing commands.
destRectScreenThe destination rectangle in screen pixels.

void TranslateWorldPx (int dx, int dy)
 Applies a world-pixel translation without rebuilding the absolute position from an integer rectangle, preserving fractional coordinates on the other axis.
void CancelVelocityComponent (bool cancelX, bool cancelY)
 Clears the requested horizontal and vertical velocity components.
override void Dispose ()
 Releases the resources owned by this instance.
void StartJiggle (float intensityX=2f, float intensityY=2f, float speed=8f, float durationSeconds=0.25f, bool loop=false, bool affectsScale=false, float scaleIntensity=0.02f, bool decay=true)
 Starts a smooth, randomized-looking jiggle animation. This jiggle is visual only and does not modify RenderSize or collision bounds.
void StopJiggle ()
 Stops the current jiggle effect.
void JiggleOnce (float intensityX=2f, float intensityY=2f, float speed=12f, float durationSeconds=0.18f, bool affectsScale=false, float scaleIntensity=0.015f)
 Starts a one-shot impact-style jiggle. Handy for hits, invalid selections, bump feedback, and similar moments.
void ResizeTo (Size targetSize, float durationSeconds)
 Smoothly resizes the sprite to an absolute pixel size.
void ScaleBy (float factor, float durationSeconds)
 Scales the sprite by a factor relative to its current render size.
void PulseTo (Size targetSize, float growDurationSeconds, float shrinkDurationSeconds, bool loop=false)
 Resizes to an absolute target size and then returns to the original size.
void PulseBy (float factor, float growDurationSeconds, float shrinkDurationSeconds, bool loop=false)
 Pulses by a factor relative to the current render size.
void StopPulse (bool snapBack=true, float returnDuration=0f)
 Stops the current pulse, optionally returning to the original size.
void CancelResize ()
 Cancels any in-progress resize or pulse.
Public Member Functions inherited from Gondwana.Drawing.Tile
virtual RectangleF GetDrawLocationScreen (View view)
 Transforms the drawable bounds into screen pixels for the specified view.
virtual RectangleF GetCollisionAreaScreen (View view)
 Transforms the collision bounds into screen pixels for the specified view.
void SetCollisionProfile (string profileName)
 Applies a named profile from this tile's parent scene. If the layer has not yet been attached to a scene, the name is retained and resolved later when the collider is attached or the profile is reapplied.
int CompareTo (Tile? tile)
 Compares this tile with another tile using their render ordering.

Properties

MovementSpace PositionSpace [get]
 Gets the coordinate space used by the position API.
float Rotation [get, set]
 Gets or sets the clockwise visual rotation, in degrees, around the center of the sprite's render rectangle.
Rectangle VisualBoundsWorld [get]
 Gets the axis-aligned world-pixel bounds enclosing the rotated sprite.
MovementController Movement = null! [get]
 Gets the controller that manages sprite movement.
override Frame CurrentFrame [get, set]
override bool Visible [get, set]
 Gets a value indicating whether the object is visible.
HorizontalAlignment HorizAlign [get, set]
 Gets or sets the horiz align.
VerticalAlignment VertAlign [get, set]
 Gets or sets the vert align.
int NudgeX [get, set]
 Gets or sets the nudge x.
int NudgeY [get, set]
 Gets or sets the nudge y.
Size RenderSize [get, set]
 Gets or sets the render size.
override Rectangle DrawLocationWorld [get]
override bool IsPositionFixed [get]
override PointF SceneLayerCoordinates [get]
override SceneLayer SceneLayer [get]
override int ZOrder [get, set]
 Gets the z-order of the element, which determines its visual stacking order relative to other elements. Higher z-order values are drawn on top of lower ones.
bool IsJiggling [get]
 Gets whether the sprite is currently jiggling.
PointF JiggleOffset [get]
 Gets the current visual jiggle offset in screen/world pixels, depending on how the sprite is being drawn.
float JiggleScale [get]
 Gets the current visual jiggle scale multiplier. This is intended to be applied at draw time only.
Properties inherited from Gondwana.Drawing.Tile
static List< Tile > TilesAnimating = new() [get]
 Gets the collection of all tiles that are currently animating in the scene.
bool IsPositionFixed [get]
 Gets whether the tile occupies a fixed position in its layer.
Rectangle DrawLocationWorld [get]
 Gets the tile drawing bounds in world pixels.
PointF SceneLayerCoordinates [get]
 Gets the position in scene-layer grid coordinates.
SceneLayer SceneLayer [get]
 Gets the scene layer that owns this tile.
Guid Id = Guid.NewGuid() [get, set]
 Gets the unique identifier.
string? Nickname [get, set]
 Gets or sets the optional lookup name.
virtual bool Visible [get, set]
 Gets or sets whether this drawable is visible.
virtual int ZOrder [get, set]
 Gets or sets the drawing order within the layer.
virtual Spacing Overhang [get]
 Gets the current frame's visual overhang beyond its tile bounds.
virtual Frame CurrentFrame [get, set]
 Gets or sets the current frame. The initial frame supplies the tile's default collision adjustment and collision type. Later frame changes update those values only when their corresponding by-frame options are enabled.
virtual Animator TileAnimator [get]
 Gets the animator associated with this tile.
virtual bool PauseAnimation [get, set]
 Gets or sets whether animation is paused.
virtual ? ICollider Collider [get]
 Gets the collision shape associated with this tile.
virtual Rectangle CollisionArea [get]
 Gets the effective collision area in world coordinates.
virtual bool EnableFog [get, set]
 Gets or sets whether scene-layer fog applies to this tile.
virtual Point[] OutlinePointsWorld [get]
 Gets the tile outline vertices in world pixels.
virtual bool AdjustCollisionAreaByFrame [get, set]
 Gets or sets whether frame changes replace the tile's collision adjustment with the newly selected frame's adjustment.
virtual CollisionAdjust AdjustCollisionArea [get, set]
 Gets or sets the collision adjustment used to derive CollisionArea.
virtual TileCollisionType CollisionType [get, set]
 Gets or sets the tile's collision behavior. This is initialized from the first assigned frame and may subsequently be overridden per tile.
virtual bool CollisionTypeByFrame [get, set]
 Gets or sets whether frame changes replace this tile's collision type with the newly selected frame's effective collision type.
string? CollisionProfileName [get]
 Gets the scene-level collision profile currently associated with this tile.
bool CollisionsEnabled [get, set]
 Gets or sets whether this tile participates in collision detection.
TypedValueBag ValueBag = new() [get]
 Gets the custom typed values associated with this object.

Events

Action< SpriteMovedEventArgs >? SpriteMoved
 Occurs when the sprite position changes.
Action< Sprite >? VisualBoundsChanged
 Occurs when the sprite visual bounds change.
Action< Sprite >? Disposing
 Occurs when disposal begins.
Action? ResizeComplete
 Raised when a resize or pulse animation completes its current leg, or when cancelled.

Additional Inherited Members

Protected Member Functions inherited from Gondwana.Drawing.Tile
void CopyCollisionSettingsFrom (Tile source)
 Copies collision behavior, profile, and effective frame metadata from another tile.
void DetachCollider ()
 Detaches the current collider from its scene-layer registry without otherwise changing this tile's serialized collision state.
void AttachCollider (ICollider collider)
 Attaches this tile's collider and applies any collision state that was set before the collider became available.
Protected Attributes inherited from Gondwana.Drawing.Tile
bool pauseAnimation
 The pause animation.
ICollider? _collider
 The collider.

Detailed Description

Represents a movable visual element on a scene layer.

Partial class containing resize and pulse animation members for Sprite.

Partial class containing jiggle animation members for Sprite.

Definition at line 19 of file Sprite.cs.

Member Function Documentation

◆ CancelResize()

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

Cancels any in-progress resize or pulse.

Definition at line 291 of file Sprite.Resize.cs.

◆ CancelVelocityComponent()

void Gondwana.Drawing.Sprites.Sprite.CancelVelocityComponent ( bool cancelX,
bool cancelY )

Clears the requested horizontal and vertical velocity components.

Parameters
cancelXWhether to clear the horizontal velocity component.
cancelYWhether to clear the vertical velocity component.

Implements Gondwana.Physics.Collisions.ICollisionMovableEntity.

Definition at line 430 of file Sprite.cs.

◆ Dispose()

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

Releases the resources owned by this instance.

Reimplemented from Gondwana.Drawing.Tile.

Definition at line 669 of file Sprite.cs.

◆ Draw()

override void Gondwana.Drawing.Sprites.Sprite.Draw ( BackbufferBase backbuffer,
RectangleF destRectScreen )
virtual

Draws the current content into the backbuffer at the supplied screen-pixel bounds.

Parameters
backbufferThe backbuffer receiving the drawing commands.
destRectScreenThe destination rectangle in screen pixels.

Reimplemented from Gondwana.Drawing.Tile.

Definition at line 371 of file Sprite.cs.

◆ GetPosition()

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

Gets the sprite position in scene-layer grid coordinates.

Returns
The sprite position in scene-layer grid coordinates.

◆ GetVisualBoundsScreen()

RectangleF Gondwana.Drawing.Sprites.Sprite.GetVisualBoundsScreen ( View view)

Gets the axis-aligned screen-pixel bounds enclosing the rotated sprite.

Parameters
viewThe view used for presentation and coordinate conversion.
Returns
The bounds in screen pixels for the supplied view.

◆ JiggleOnce()

void Gondwana.Drawing.Sprites.Sprite.JiggleOnce ( float intensityX = 2f,
float intensityY = 2f,
float speed = 12f,
float durationSeconds = 0::18f,
bool affectsScale = false,
float scaleIntensity = 0::015f )

Starts a one-shot impact-style jiggle. Handy for hits, invalid selections, bump feedback, and similar moments.

Parameters
intensityXThe intensity x.
intensityYThe intensity y.
speedThe speed.
durationSecondsThe duration in seconds.
affectsScaleWhether the effect also changes the drawing scale.
scaleIntensityThe scale intensity.

Definition at line 270 of file Sprite.Jiggle.cs.

◆ PulseBy()

void Gondwana.Drawing.Sprites.Sprite.PulseBy ( float factor,
float growDurationSeconds,
float shrinkDurationSeconds,
bool loop = false )

Pulses by a factor relative to the current render size.

Parameters
factorThe factor.
growDurationSecondsThe grow duration seconds.
shrinkDurationSecondsThe shrink duration seconds.
loopWhether playback repeats at the end.

Definition at line 244 of file Sprite.Resize.cs.

◆ PulseTo()

void Gondwana.Drawing.Sprites.Sprite.PulseTo ( Size targetSize,
float growDurationSeconds,
float shrinkDurationSeconds,
bool loop = false )

Resizes to an absolute target size and then returns to the original size.

Parameters
targetSizeThe target size.
growDurationSecondsThe grow duration seconds.
shrinkDurationSecondsThe shrink duration seconds.
loopWhether playback repeats at the end.

Definition at line 210 of file Sprite.Resize.cs.

◆ ResizeTo()

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

Smoothly resizes the sprite to an absolute pixel size.

Parameters
targetSizeThe target size.
durationSecondsThe duration in seconds.

Definition at line 168 of file Sprite.Resize.cs.

◆ ScaleBy()

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

Scales the sprite by a factor relative to its current render size.

Parameters
factorThe factor.
durationSecondsThe duration in seconds.

Definition at line 191 of file Sprite.Resize.cs.

◆ SetPosition()

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

Sets the sprite position in scene-layer grid coordinates and invalidates its old and new bounds.

Parameters
posThe new position in scene-layer grid coordinates.

Definition at line 306 of file Sprite.cs.

◆ StartJiggle()

void Gondwana.Drawing.Sprites.Sprite.StartJiggle ( float intensityX = 2f,
float intensityY = 2f,
float speed = 8f,
float durationSeconds = 0::25f,
bool loop = false,
bool affectsScale = false,
float scaleIntensity = 0::02f,
bool decay = true )

Starts a smooth, randomized-looking jiggle animation. This jiggle is visual only and does not modify RenderSize or collision bounds.

Parameters
intensityXMaximum horizontal jiggle in pixels.
intensityYMaximum vertical jiggle in pixels.
speedHow quickly the jiggle animates.
durationSecondsDuration of the jiggle. Ignored if loop is true.
loopWhether the jiggle should continue indefinitely.
affectsScaleWhether to add a subtle visual size wobble during the jiggle.
scaleIntensityMaximum scale wobble amount. Example: 0.03 = about ±3%.
decayWhether the jiggle should gradually fade out over its duration.

Definition at line 84 of file Sprite.Jiggle.cs.

◆ StopJiggle()

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

Stops the current jiggle effect.

Definition at line 125 of file Sprite.Jiggle.cs.

◆ StopPulse()

void Gondwana.Drawing.Sprites.Sprite.StopPulse ( bool snapBack = true,
float returnDuration = 0f )

Stops the current pulse, optionally returning to the original size.

Parameters
snapBackWhether to restore the original position when the effect ends.
returnDurationThe return duration.

Definition at line 267 of file Sprite.Resize.cs.

◆ TranslateWorldPx()

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

Applies a world-pixel translation without rebuilding the absolute position from an integer rectangle, preserving fractional coordinates on the other axis.

Parameters
dxThe horizontal displacement in world pixels.
dyThe vertical displacement in world pixels.

Implements Gondwana.Physics.Collisions.ICollisionMovableEntity.

Definition at line 403 of file Sprite.cs.

Property Documentation

◆ CurrentFrame

override Frame Gondwana.Drawing.Sprites.Sprite.CurrentFrame
getset

Definition at line 443 of file Sprite.cs.

◆ DrawLocationWorld

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

Definition at line 578 of file Sprite.cs.

◆ HorizAlign

HorizontalAlignment Gondwana.Drawing.Sprites.Sprite.HorizAlign
getset

Gets or sets the horiz align.

Definition at line 470 of file Sprite.cs.

◆ IsJiggling

bool Gondwana.Drawing.Sprites.Sprite.IsJiggling
get

Gets whether the sprite is currently jiggling.

Definition at line 49 of file Sprite.Jiggle.cs.

◆ IsPositionFixed

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

Definition at line 616 of file Sprite.cs.

◆ JiggleOffset

PointF Gondwana.Drawing.Sprites.Sprite.JiggleOffset
get

Gets the current visual jiggle offset in screen/world pixels, depending on how the sprite is being drawn.

Definition at line 55 of file Sprite.Jiggle.cs.

◆ JiggleScale

float Gondwana.Drawing.Sprites.Sprite.JiggleScale
get

Gets the current visual jiggle scale multiplier. This is intended to be applied at draw time only.

Definition at line 61 of file Sprite.Jiggle.cs.

◆ Movement

MovementController Gondwana.Drawing.Sprites.Sprite.Movement = null!
get

Gets the controller that manages sprite movement.

Definition at line 439 of file Sprite.cs.

◆ NudgeX

int Gondwana.Drawing.Sprites.Sprite.NudgeX
getset

Gets or sets the nudge x.

Definition at line 514 of file Sprite.cs.

◆ NudgeY

int Gondwana.Drawing.Sprites.Sprite.NudgeY
getset

Gets or sets the nudge y.

Definition at line 536 of file Sprite.cs.

◆ PositionSpace

MovementSpace Gondwana.Drawing.Sprites.Sprite.PositionSpace
get

Gets the coordinate space used by the position API.

Definition at line 293 of file Sprite.cs.

◆ RenderSize

Size Gondwana.Drawing.Sprites.Sprite.RenderSize
getset

Gets or sets the render size.

Definition at line 558 of file Sprite.cs.

◆ Rotation

float Gondwana.Drawing.Sprites.Sprite.Rotation
getset

Gets or sets the clockwise visual rotation, in degrees, around the center of the sprite's render rectangle.

Rotation affects rendering and dirty-region bounds. Collision geometry remains axis-aligned and continues to use Tile.CollisionArea.

Definition at line 331 of file Sprite.cs.

◆ SceneLayer

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

Definition at line 624 of file Sprite.cs.

◆ SceneLayerCoordinates

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

Definition at line 620 of file Sprite.cs.

◆ VertAlign

VerticalAlignment Gondwana.Drawing.Sprites.Sprite.VertAlign
getset

Gets or sets the vert align.

Definition at line 492 of file Sprite.cs.

◆ Visible

override bool Gondwana.Drawing.Sprites.Sprite.Visible
getset

Gets a value indicating whether the object is visible.

Implements Gondwana.Drawing.IDrawable.

Definition at line 456 of file Sprite.cs.

◆ VisualBoundsWorld

Rectangle Gondwana.Drawing.Sprites.Sprite.VisualBoundsWorld
get

Gets the axis-aligned world-pixel bounds enclosing the rotated sprite.

Definition at line 356 of file Sprite.cs.

◆ ZOrder

override int Gondwana.Drawing.Sprites.Sprite.ZOrder
getset

Gets the z-order of the element, which determines its visual stacking order relative to other elements. Higher z-order values are drawn on top of lower ones.

Implements Gondwana.Drawing.IDrawable.

Definition at line 628 of file Sprite.cs.

Event Documentation

◆ Disposing

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

Occurs when disposal begins.

Definition at line 32 of file Sprite.cs.

◆ ResizeComplete

Action? Gondwana.Drawing.Sprites.Sprite.ResizeComplete

Raised when a resize or pulse animation completes its current leg, or when cancelled.

Definition at line 14 of file Sprite.Resize.cs.

◆ SpriteMoved

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

Occurs when the sprite position changes.

Definition at line 24 of file Sprite.cs.

◆ VisualBoundsChanged

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

Occurs when the sprite visual bounds change.

Definition at line 28 of file Sprite.cs.