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.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.Movement.IMovableOnSceneLayer Gondwana.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 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 relative to the CURRENT composite anchor (derived from Range).
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< SpriteChildren [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.

Constructor & Destructor Documentation

◆ CompositeSprite() [1/3]

Gondwana.Drawing.Sprites.CompositeSprite.CompositeSprite ( )

Initializes a new instance of the CompositeSprite class.

◆ 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.

◆ 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.

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.

◆ 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.

◆ 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 relative to the CURRENT composite anchor (derived from Range).

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.

◆ GetPosition()

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

Gets the current position of the composite sprite based on its anchor mode.

Returns
The position of the composite's anchor point.

Implements Gondwana.Movement.IMovable.

◆ Remove()

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

Removes a sprite from this composite.

Parameters
spriteThe sprite to remove.

◆ 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.Movement.IMovable.

◆ Translate()

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

Translates the composite sprite by the specified delta vector.

Parameters
deltaThe translation vector to apply.

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.

◆ Children

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

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

◆ PositionSpace

MovementSpace Gondwana.Drawing.Sprites.CompositeSprite.PositionSpace
get

Gets the movement space used for positioning this composite sprite.

Implements Gondwana.Movement.IMovable.

◆ 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.

◆ 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.Movement.IMovableOnSceneLayer.