ParticleLayer
Declaration
public class Strawberry.Graphics.Layers.ParticleLayer
A layer responsible for managing and rendering particle emitters within a scene.
Inherits: Strawberry.Graphics.Layers.Layer
Constructors
ParticleLayer
Initializes a new instance of the ParticleLayer class.
void ParticleLayer()
Properties
GraphicsContext
Gets the graphics context associated with the current scene.
IGraphicsContext GraphicsContext { get }
DrawCalls
Gets or sets the number of draw calls performed during the last render.
int DrawCalls { get set }
AliveParticleCount
Gets the number of live particles currently active in the layer.
int AliveParticleCount { get }
EmitterCount
Gets the number of particle emitters attached to this layer.
int EmitterCount { get }
Methods
Initialize override
Initializes the particle layer, allocates buffers, and prepares the geometry.
void Initialize(Scene scene)
Parameters:
| Name | Type | Description |
|---|---|---|
scene |
Strawberry.Core.Scene |
The scene that owns the layer. |
AddEmitter
Creates and adds a new particle emitter to the layer.
ParticleEmitter AddEmitter(Sprite sprite, ParticleInitiator initiator, ParticleTimeline timeline)
Parameters:
| Name | Type | Description |
|---|---|---|
sprite |
Strawberry.Graphics.Sprite |
The sprite used by the emitter. |
initiator |
Strawberry.Graphics.ParticleSystem.ParticleInitiator |
The particle initiator that generates particles. |
timeline |
Strawberry.Graphics.ParticleSystem.ParticleTimeline |
The particle timeline that updates particle properties. |
Returns: The created emitter.
AddEmitter
Adds an existing particle emitter to the layer.
ParticleEmitter AddEmitter(ParticleEmitter emitter)
Parameters:
| Name | Type | Description |
|---|---|---|
emitter |
Strawberry.Graphics.ParticleSystem.ParticleEmitter |
The emitter to add. |
Returns: The emitter that was added.
RemoveEmitter
Removes a particle emitter from the layer.
bool RemoveEmitter(ParticleEmitter emitter)
Parameters:
| Name | Type | Description |
|---|---|---|
emitter |
Strawberry.Graphics.ParticleSystem.ParticleEmitter |
The emitter to remove. |
Returns: True if the emitter was removed; otherwise false.
GetEmitter
Gets the particle emitter at the specified index.
ParticleEmitter GetEmitter(int index)
Parameters:
| Name | Type | Description |
|---|---|---|
index |
System.Int32 |
The zero-based index of the emitter. |
Returns: The emitter if found; otherwise null.
ClearEmitters
Removes all emitters and deactivates all live particles.
void ClearEmitters()
SetBlendMode
Sets the blend mode name used when rendering particles.
void SetBlendMode(string name)
Parameters:
| Name | Type | Description |
|---|---|---|
name |
System.String |
The blend mode identifier. |
Update override
Updates all particle emitters and active particles.
void Update()
Render override
Renders all active particles in the layer.
void Render()