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.CompositeSprite Class Reference

Represents a composite sprite that contains multiple child sprites and manages them as a single unit. All child sprites must belong to the same SceneLayer. More...

Inheritance diagram for Gondwana.Drawing.Sprites.CompositeSprite:
Gondwana.Physics.Movement.IMovableOnSceneLayer Gondwana.Physics.Movement.IMovable

Public Member Functions

 CompositeSprite ()
 Initializes a new instance of the CompositeSprite class.
 CompositeSprite (List< Sprite > sprites)
 Initializes a new instance of the CompositeSprite class with the specified list of sprites.
 CompositeSprite (params Sprite[] sprites)
 Initializes a new instance of the CompositeSprite class with the specified array of sprites.
Vector2 GetPosition ()
 Gets the current position of the composite sprite in scene-layer grid coordinates, based on its anchor mode.
void SetPosition (Vector2 pos)
 Sets the position of the composite sprite by moving all child sprites to maintain their relative positions.
void Translate (Vector2 delta)
 Translates the composite sprite by the specified delta vector.
void Add (Sprite sprite)
 Adds an existing sprite at its current position (no reposition).
void AddChildAtPosition (Sprite sprite, Vector2 absolutePosition)
 Add a sprite and place it at an absolute position (in the composite's PositionSpace).
void AddChildWithOffset (Sprite sprite, Vector2 offsetFromCompositeAnchor)
 Add a sprite and place it by offset from the composite anchor. Offset is interpreted in grid coordinates relative to the current composite anchor.
void Remove (Sprite sprite)
 Removes a sprite from this composite.

Properties

CompositeAnchorMode AnchorMode = CompositeAnchorMode.TopLeft [get, set]
 Gets or sets the anchor mode that determines how the composite's position is calculated relative to its children.
MovementSpace PositionSpace [get]
 Gets the movement space used for positioning this composite sprite.
SceneLayer SceneLayer [get]
 Gets the scene layer that all child sprites belong to.
ReadOnlyCollection< Sprite > Children [get]
 Gets a read-only collection of all child sprites in this composite.
Rectangle Range [get]
 Gets the bounding rectangle that encompasses all child sprites. Returns Rectangle.Empty if there are no children.

Detailed Description

Represents a composite sprite that contains multiple child sprites and manages them as a single unit. All child sprites must belong to the same SceneLayer.

Definition at line 15 of file CompositeSprite.cs.

Constructor & Destructor Documentation

◆ CompositeSprite() [1/3]

Gondwana.Drawing.Sprites.CompositeSprite.CompositeSprite ( )

Initializes a new instance of the CompositeSprite class.

Definition at line 31 of file CompositeSprite.cs.

◆ CompositeSprite() [2/3]

Gondwana.Drawing.Sprites.CompositeSprite.CompositeSprite ( List< Sprite > sprites)

Initializes a new instance of the CompositeSprite class with the specified list of sprites.

Parameters
spritesThe list of sprites to add to this composite.

Definition at line 37 of file CompositeSprite.cs.

◆ CompositeSprite() [3/3]

Gondwana.Drawing.Sprites.CompositeSprite.CompositeSprite ( params Sprite[] sprites)

Initializes a new instance of the CompositeSprite class with the specified array of sprites.

Parameters
spritesThe array of sprites to add to this composite.

Definition at line 47 of file CompositeSprite.cs.

Member Function Documentation

◆ Add()

void Gondwana.Drawing.Sprites.CompositeSprite.Add ( Sprite sprite)

Adds an existing sprite at its current position (no reposition).

Parameters
spriteThe sprite to add to this composite.
Exceptions
ArgumentNullExceptionThrown when sprite is null.
InvalidOperationExceptionThrown when the sprite belongs to a different SceneLayer than existing children.

Definition at line 152 of file CompositeSprite.cs.

◆ AddChildAtPosition()

void Gondwana.Drawing.Sprites.CompositeSprite.AddChildAtPosition ( Sprite sprite,
Vector2 absolutePosition )

Add a sprite and place it at an absolute position (in the composite's PositionSpace).

Parameters
spriteThe sprite to add to this composite.
absolutePositionThe absolute position to place the sprite at.
Exceptions
ArgumentNullExceptionThrown when sprite is null.
InvalidOperationExceptionThrown when the sprite belongs to a different SceneLayer than existing children.

Definition at line 170 of file CompositeSprite.cs.

◆ AddChildWithOffset()

void Gondwana.Drawing.Sprites.CompositeSprite.AddChildWithOffset ( Sprite sprite,
Vector2 offsetFromCompositeAnchor )

Add a sprite and place it by offset from the composite anchor. Offset is interpreted in grid coordinates relative to the current composite anchor.

Parameters
spriteThe sprite to add to this composite.
offsetFromCompositeAnchorThe offset from the composite's anchor point.
Exceptions
ArgumentNullExceptionThrown when sprite is null.
InvalidOperationExceptionThrown when the sprite belongs to a different SceneLayer than existing children.

Definition at line 191 of file CompositeSprite.cs.

◆ GetPosition()

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

Gets the current position of the composite sprite in scene-layer grid coordinates, based on its anchor mode.

Returns
The grid-space position of the composite's anchor point.

Implements Gondwana.Physics.Movement.IMovable.

Definition at line 90 of file CompositeSprite.cs.

◆ Remove()

void Gondwana.Drawing.Sprites.CompositeSprite.Remove ( Sprite sprite)

Removes a sprite from this composite.

Parameters
spriteThe sprite to remove.

Definition at line 224 of file CompositeSprite.cs.

◆ SetPosition()

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

Sets the position of the composite sprite by moving all child sprites to maintain their relative positions.

Parameters
posThe new position for the composite's anchor point.

Implements Gondwana.Physics.Movement.IMovable.

Definition at line 113 of file CompositeSprite.cs.

◆ Translate()

void Gondwana.Drawing.Sprites.CompositeSprite.Translate ( Vector2 delta)

Translates the composite sprite by the specified delta vector.

Parameters
deltaThe translation vector to apply.

Definition at line 134 of file CompositeSprite.cs.

Property Documentation

◆ AnchorMode

CompositeAnchorMode Gondwana.Drawing.Sprites.CompositeSprite.AnchorMode = CompositeAnchorMode.TopLeft
getset

Gets or sets the anchor mode that determines how the composite's position is calculated relative to its children.

Definition at line 24 of file CompositeSprite.cs.

◆ Children

ReadOnlyCollection<Sprite> Gondwana.Drawing.Sprites.CompositeSprite.Children
get

Gets a read-only collection of all child sprites in this composite.

Definition at line 264 of file CompositeSprite.cs.

◆ PositionSpace

MovementSpace Gondwana.Drawing.Sprites.CompositeSprite.PositionSpace
get

Gets the movement space used for positioning this composite sprite.

Implements Gondwana.Physics.Movement.IMovable.

Definition at line 66 of file CompositeSprite.cs.

◆ Range

Rectangle Gondwana.Drawing.Sprites.CompositeSprite.Range
get

Gets the bounding rectangle that encompasses all child sprites. Returns Rectangle.Empty if there are no children.

Definition at line 271 of file CompositeSprite.cs.

◆ SceneLayer

SceneLayer Gondwana.Drawing.Sprites.CompositeSprite.SceneLayer
get

Gets the scene layer that all child sprites belong to.

Exceptions
InvalidOperationExceptionThrown when the composite has no children.

Implements Gondwana.Physics.Movement.IMovableOnSceneLayer.

Definition at line 73 of file CompositeSprite.cs.