ParticleItem
Represents a single particle in a particle system.
ParticleItem holds all the data for an individual particle including its physical properties, visual appearance, and animation state. Particles are managed by ParticleEmitter and should not be instantiated directly by user code.
The particle's properties can change over its lifetime through:
- Linear interpolation between start and end values
- Physics simulation (velocity, acceleration, drag)
- Direct property manipulation
Visual synchronization: When visual*Active flags are true, the particle automatically updates the corresponding properties on its visual. This allows the particle system to control the visual appearance efficiently.
Instance Members
visual: VisualThe visual representation of this particle. Can be any Visual subclass (Quad, Mesh, etc.). Managed by the ParticleEmitter's pooling system.
visualScaleActive: BoolWhether particle scale should be applied to the visual. When true, changes to scaleX/scaleY update visual.scaleX/scaleY.
visualColorActive: BoolWhether particle color should be applied to the visual. When true, changes to color update visual's color (for Quad/Mesh).
visualPositionActive: BoolWhether particle position should be applied to the visual. When true, changes to x/y update visual.x/y.
visualRotationActive: BoolWhether particle angle should be applied to the visual. When true, changes to angle update visual.rotation.
visualAlphaActive: BoolWhether particle alpha should be applied to the visual. When true, changes to alpha update visual.alpha.
active: BoolWhether this particle is currently active in the simulation. Inactive particles are in the recycling pool.
lifespan: FloatTotal lifetime of the particle in seconds. When age >= lifespan, the particle is recycled. Set to 0 for infinite lifetime.
age: FloatCurrent age of the particle in seconds. Increases each update by delta time. Used to calculate interpolation progress.
time: FloatThe timestamp when this particle was emitted. Uses Timer.now for absolute time reference. Useful for time-based effects or debugging.
random: FloatA random value between 0 and 1 unique to this particle. Generated when emitted, remains constant during lifetime. Useful for randomizing behavior without additional RNG calls.
status: IntCustom status field for user-defined particle states. Can be used to track special conditions, animation states, or any integer-based status specific to your implementation.
colorRangeActive: BoolWhether color interpolation over lifetime is active. When true, color interpolates from colorRangeStart to colorRangeEnd.
colorRangeStart: ColorStarting color for interpolation. The particle begins with this color at age 0.
colorRangeEnd: ColorEnding color for interpolation. The particle reaches this color at the end of its lifespan.
color: ColorCurrent color of the particle. When visualColorActive is true, automatically syncs with visual's color. Supports Quad and Mesh visuals.
accelerationRangeActive: BoolWhether acceleration interpolation over lifetime is active.
accelerationRangeStartX: FloatStarting X acceleration for interpolation.
accelerationRangeStartY: FloatStarting Y acceleration for interpolation.
accelerationRangeEndX: FloatEnding X acceleration for interpolation.
accelerationRangeEndY: FloatEnding Y acceleration for interpolation.
accelerationX: FloatCurrent X acceleration in pixels per second squared. Positive values accelerate right, negative left.
accelerationY: FloatCurrent Y acceleration in pixels per second squared. Positive values accelerate down, negative up. Common use: positive value for gravity effect.
dragRangeActive: BoolWhether drag interpolation over lifetime is active.
dragRangeStartX: FloatStarting X drag coefficient for interpolation.
dragRangeStartY: FloatStarting Y drag coefficient for interpolation.
dragRangeEndX: FloatEnding X drag coefficient for interpolation.
dragRangeEndY: FloatEnding Y drag coefficient for interpolation.
dragX: FloatCurrent X drag coefficient. Reduces velocity over time, simulating air resistance. Higher values = more resistance.
dragY: FloatCurrent Y drag coefficient. Reduces velocity over time, simulating air resistance. Higher values = more resistance.
velocityRangeActive: BoolWhether velocity interpolation over lifetime is active.
velocityRangeStartX: FloatStarting X velocity for interpolation.
velocityRangeStartY: FloatStarting Y velocity for interpolation.
velocityRangeEndX: FloatEnding X velocity for interpolation.
velocityRangeEndY: FloatEnding Y velocity for interpolation.
velocityX: FloatCurrent X velocity in pixels per second. Positive = right, negative = left.
velocityY: FloatCurrent Y velocity in pixels per second. Positive = down, negative = up.
angularVelocityRangeActive: BoolWhether angular velocity interpolation over lifetime is active.
angularVelocityRangeStart: FloatStarting angular velocity for interpolation.
angularVelocityRangeEnd: FloatEnding angular velocity for interpolation.
angularVelocity: FloatCurrent angular velocity in degrees per second. Positive = clockwise, negative = counter-clockwise.
angularAccelerationRangeActive: BoolWhether angular acceleration is active. Note: Currently doesn't support interpolation.
angularAccelerationRangeStart: FloatStarting angular acceleration (unused currently).
angularAccelerationRangeEnd: FloatEnding angular acceleration (unused currently).
angularAcceleration: FloatAngular acceleration in degrees per second squared. Changes angular velocity over time.
angularDrag: FloatAngular drag coefficient. Reduces angular velocity over time. Higher values = more rotational resistance.
scaleRangeActive: BoolWhether scale interpolation over lifetime is active.
scaleRangeStartX: FloatStarting X scale for interpolation.
scaleRangeStartY: FloatStarting Y scale for interpolation.
scaleRangeEndX: FloatEnding X scale for interpolation.
scaleRangeEndY: FloatEnding Y scale for interpolation.
scaleX: FloatCurrent X scale factor. When visualScaleActive is true, automatically syncs with visual.scaleX. 1.0 = normal size, 2.0 = double width, 0.5 = half width.
scaleY: FloatCurrent Y scale factor. When visualScaleActive is true, automatically syncs with visual.scaleY. 1.0 = normal size, 2.0 = double height, 0.5 = half height.
x: FloatCurrent X position in pixels. When visualPositionActive is true, automatically syncs with visual.x. Relative to the particle's parent visual.
y: FloatCurrent Y position in pixels. When visualPositionActive is true, automatically syncs with visual.y. Relative to the particle's parent visual.
angle: FloatCurrent rotation angle in degrees. When visualRotationActive is true, automatically syncs with visual.rotation. 0 = no rotation, 90 = quarter turn clockwise.
alphaRangeActive: BoolWhether alpha interpolation over lifetime is active.
alphaRangeStart: FloatStarting alpha for interpolation. 1.0 = fully opaque.
alphaRangeEnd: FloatEnding alpha for interpolation. 0.0 = fully transparent.
alpha: FloatCurrent alpha transparency. When visualAlphaActive is true, automatically syncs with visual.alpha. Range: 0.0 (invisible) to 1.0 (opaque).
Sets both X and Y scale factors at once.
| Name | Type | Description |
|---|---|---|
scaleX |
Float | Horizontal scale factor |
scaleY |
Float | Vertical scale factor |
Sets both X and Y position at once.
| Name | Type | Description |
|---|---|---|
x |
Float | Horizontal position in pixels |
y |
Float | Vertical position in pixels |
reset(): VoidResets all particle properties to default values.
Called by ParticleEmitter when recycling a particle. Ensures clean state for reused particles.
Private Members
new(): VoidPrivate constructor - ParticleItems are created and managed by ParticleEmitter. User code should not instantiate particles directly.
Metadata
| Name | Parameters |
|---|---|
:allow |
ceramic.ParticleEmitter |