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.Direct.Particles.ParticleEmitter Class Referencesealed

Configures how particles are spawned over time at a given location. More...

Public Attributes

float Min
 Lifetime range in seconds (min, max).

Properties

PointF Position [get, set]
 RenderHost / adapter pixel position where particles originate.
float EmitRate = 200f [get, set]
 Particles per second to spawn (fractional allowed).
float float Max LifeRange = (0.6f, 1.4f) [get, set]
float float Max VelocityRangeX = (-120f, 120f) [get, set]
float float Max VelocityRangeY = (-300f, -180f) [get, set]
float float Max SizeRange = (3f, 7f) [get, set]
SKColor Color = new SKColor(200, 200, 255, 255) [get, set]
 Base color. Alpha will be modulated by lifetime fade. You can randomize in OnSpawn if desired.
SKBlendMode BlendMode = SKBlendMode.Plus [get, set]
 Blend mode used when rendering particles from this emitter. Defaults to SKBlendMode.Plus for additive/glowy effects.
float JitterX = 0f [get, set]
 Gets or sets the horizontal jitter value for spawning particles, which represents a random offset applied along the X-axis.
float JitterY = 0f [get, set]
 Gets or sets the vertical jitter value for spawning particles, which represents a random offset applied along the Y-axis.
float? GravityX = null [get, set]
 Gets or sets the horizontal component of the gravity vector in pixels per second squared (px/s²). Negative values pull left, positive values pull right. If null, the emitter uses the global gravity setting from the ParticleSurface. Default ParticleSurface.GravityX is 0."/>
float? GravityY = null [get, set]
 Gets or sets the vertical component of the gravity vector in pixels per second squared (px/s²). Negative values pull up, positive values pull down. If null, the emitter uses the global gravity setting from the ParticleSurface. Default ParticleSurface.GravityY is 400."/>
SKBitmap? ParticleSprite [get, set]
 Optional sprite used for particles spawned by this emitter. If null, the particle surface’s default sprite is used (or a circle if none).
SKColor? Tint [get, set]
 Optional per-emitter tint. If set, it overrides the particle system's GlobalColorTint for particles spawned by this emitter.
float? MaxVelocity [get, set]
 Optional per-emitter maximum speed in px/s. If set, particle velocity will be clamped to this magnitude after acceleration is applied each update.
ParticleSpawnDistribution SpawnDistribution = ParticleSpawnDistribution.Rectangle [get, set]
 Controls the random spawn distribution used by JitterX/JitterY.
float RingInnerRadius01 = 0.85f [get, set]
 For Ring distribution: inner radius as a fraction of the outer radius [0..1]. 0 = filled disk, 0.8 = thin-ish ring, 0.95 = very thin ring.
float GaussianStdDev01 = 0.33f [get, set]
 For Gaussian distribution: standard deviation as a fraction of outer radius. Typical values: 0.25 to 0.5. Higher spreads wider.
ParticleSpawnHandler? OnSpawn [get, set]
 Optional per-particle customization hook (e.g., perlin drift, hue jitter).
Action< ParticleEmitter, float >? OnUpdate [get, set]
 Optional per-frame callback to tweak emitter (e.g., move with an object).

Detailed Description

Configures how particles are spawned over time at a given location.

A ParticleEmitter defines how particles are spawned over time at a specific position. Each emitter manages its own emission rate, lifetime ranges, velocity ranges, size ranges, and base color.

You can also attach two optional hooks:

  • OnSpawn — called once for each newly created particle, giving you a ref to the particle for last-mile initialization (e.g., randomizing rotation, adjusting color, assigning metadata, etc.).
  • OnUpdate — called every update tick with the emitter and elapsed time (seconds). This can be used to animate emitter motion (e.g., moving with a torch, oscillating with a sine wave, etc.).

Emitters are usually created in pairs or groups and added to a ParticleSurface system to combine effects. For example, one emitter can generate fast-fading sparks while another generates slow-rising smoke.

The following demonstrates how to configure multiple emitters for different particle effects (e.g., fire sparks and campfire smoke).

// Example: Fire pit with glowing sparks + rising smoke
var particles = new DirectParticles(renderHost,
new Rectangle(0, 0, viewportW, viewportH));
// Configure base behavior
particles.GravityY = 300f; // pull particles down
// Define an emitter for sparks
var sparks = new ParticleEmitter
{
Position = new PointF(400, 550),
EmitRate = 400,
LifeRange = (0.5f, 1.0f),
VelocityRangeX = (-150f, 150f),
VelocityRangeY = (-300f, -200f),
SizeRange = (2f, 4f),
Color = SKColors.OrangeRed
};
// Define an emitter for smoke
var smoke = new ParticleEmitter
{
Position = new PointF(400, 540),
EmitRate = 120,
LifeRange = (2.5f, 4.0f),
VelocityRangeX = (-40f, 40f),
VelocityRangeY = (-120f, -60f),
SizeRange = (8f, 16f),
Color = new SKColor(80, 80, 80, 200) // semi-transparent gray
};
// Add emitters to the particle system
particles.Emitters.Add(sparks);
particles.Emitters.Add(smoke);
// Register with the manager
directDrawingManager.AddOrReplace(particles);
Configures how particles are spawned over time at a given location.
SKColor Color
Base color. Alpha will be modulated by lifetime fade. You can randomize in OnSpawn if desired.
float EmitRate
Particles per second to spawn (fractional allowed).
PointF Position
RenderHost / adapter pixel position where particles originate.
@ Rectangle
Particles are spawned uniformly within a rectangular area. This is the default distribution.

Definition at line 92 of file ParticleEmitter.cs.

Member Data Documentation

◆ Min

float Gondwana.Drawing.Direct.Particles.ParticleEmitter.Min

Lifetime range in seconds (min, max).

Size range in pixels (min, max). Interpreted as diameter for circles, edge for quads.

Initial Y velocity range in px/s (min, max). Negative shoots upward.

Initial X velocity range in px/s (min, max).

Definition at line 101 of file ParticleEmitter.cs.

Property Documentation

◆ BlendMode

SKBlendMode Gondwana.Drawing.Direct.Particles.ParticleEmitter.BlendMode = SKBlendMode.Plus
getset

Blend mode used when rendering particles from this emitter. Defaults to SKBlendMode.Plus for additive/glowy effects.

Definition at line 121 of file ParticleEmitter.cs.

◆ Color

SKColor Gondwana.Drawing.Direct.Particles.ParticleEmitter.Color = new SKColor(200, 200, 255, 255)
getset

Base color. Alpha will be modulated by lifetime fade. You can randomize in OnSpawn if desired.

Definition at line 115 of file ParticleEmitter.cs.

◆ EmitRate

float Gondwana.Drawing.Direct.Particles.ParticleEmitter.EmitRate = 200f
getset

Particles per second to spawn (fractional allowed).

Definition at line 98 of file ParticleEmitter.cs.

◆ GaussianStdDev01

float Gondwana.Drawing.Direct.Particles.ParticleEmitter.GaussianStdDev01 = 0.33f
getset

For Gaussian distribution: standard deviation as a fraction of outer radius. Typical values: 0.25 to 0.5. Higher spreads wider.

Definition at line 180 of file ParticleEmitter.cs.

◆ GravityX

float? Gondwana.Drawing.Direct.Particles.ParticleEmitter.GravityX = null
getset

Gets or sets the horizontal component of the gravity vector in pixels per second squared (px/s²). Negative values pull left, positive values pull right. If null, the emitter uses the global gravity setting from the ParticleSurface. Default ParticleSurface.GravityX is 0."/>

Definition at line 138 of file ParticleEmitter.cs.

◆ GravityY

float? Gondwana.Drawing.Direct.Particles.ParticleEmitter.GravityY = null
getset

Gets or sets the vertical component of the gravity vector in pixels per second squared (px/s²). Negative values pull up, positive values pull down. If null, the emitter uses the global gravity setting from the ParticleSurface. Default ParticleSurface.GravityY is 400."/>

Definition at line 145 of file ParticleEmitter.cs.

◆ JitterX

float Gondwana.Drawing.Direct.Particles.ParticleEmitter.JitterX = 0f
getset

Gets or sets the horizontal jitter value for spawning particles, which represents a random offset applied along the X-axis.

Definition at line 126 of file ParticleEmitter.cs.

◆ JitterY

float Gondwana.Drawing.Direct.Particles.ParticleEmitter.JitterY = 0f
getset

Gets or sets the vertical jitter value for spawning particles, which represents a random offset applied along the Y-axis.

Definition at line 131 of file ParticleEmitter.cs.

◆ LifeRange

float float Max Gondwana.Drawing.Direct.Particles.ParticleEmitter.LifeRange = (0.6f, 1.4f)
getset

Definition at line 101 of file ParticleEmitter.cs.

◆ MaxVelocity

float? Gondwana.Drawing.Direct.Particles.ParticleEmitter.MaxVelocity
getset

Optional per-emitter maximum speed in px/s. If set, particle velocity will be clamped to this magnitude after acceleration is applied each update.

Definition at line 163 of file ParticleEmitter.cs.

◆ OnSpawn

ParticleSpawnHandler? Gondwana.Drawing.Direct.Particles.ParticleEmitter.OnSpawn
getset

Optional per-particle customization hook (e.g., perlin drift, hue jitter).

Definition at line 183 of file ParticleEmitter.cs.

◆ OnUpdate

Action<ParticleEmitter, float>? Gondwana.Drawing.Direct.Particles.ParticleEmitter.OnUpdate
getset

Optional per-frame callback to tweak emitter (e.g., move with an object).

Definition at line 186 of file ParticleEmitter.cs.

◆ ParticleSprite

SKBitmap? Gondwana.Drawing.Direct.Particles.ParticleEmitter.ParticleSprite
getset

Optional sprite used for particles spawned by this emitter. If null, the particle surface’s default sprite is used (or a circle if none).

Definition at line 151 of file ParticleEmitter.cs.

◆ Position

PointF Gondwana.Drawing.Direct.Particles.ParticleEmitter.Position
getset

RenderHost / adapter pixel position where particles originate.

Definition at line 95 of file ParticleEmitter.cs.

◆ RingInnerRadius01

float Gondwana.Drawing.Direct.Particles.ParticleEmitter.RingInnerRadius01 = 0.85f
getset

For Ring distribution: inner radius as a fraction of the outer radius [0..1]. 0 = filled disk, 0.8 = thin-ish ring, 0.95 = very thin ring.

Definition at line 174 of file ParticleEmitter.cs.

◆ SizeRange

float float Max Gondwana.Drawing.Direct.Particles.ParticleEmitter.SizeRange = (3f, 7f)
getset

Definition at line 110 of file ParticleEmitter.cs.

◆ SpawnDistribution

ParticleSpawnDistribution Gondwana.Drawing.Direct.Particles.ParticleEmitter.SpawnDistribution = ParticleSpawnDistribution.Rectangle
getset

Controls the random spawn distribution used by JitterX/JitterY.

Definition at line 168 of file ParticleEmitter.cs.

◆ Tint

SKColor? Gondwana.Drawing.Direct.Particles.ParticleEmitter.Tint
getset

Optional per-emitter tint. If set, it overrides the particle system's GlobalColorTint for particles spawned by this emitter.

Definition at line 157 of file ParticleEmitter.cs.

◆ VelocityRangeX

float float Max Gondwana.Drawing.Direct.Particles.ParticleEmitter.VelocityRangeX = (-120f, 120f)
getset

Definition at line 104 of file ParticleEmitter.cs.

◆ VelocityRangeY

float float Max Gondwana.Drawing.Direct.Particles.ParticleEmitter.VelocityRangeY = (-300f, -180f)
getset

Definition at line 107 of file ParticleEmitter.cs.