CCParticleEmitterLight
CCParticleEmitterLight
Cocos2DA lightweight, struct-based particle emitter that renders via CCDrawNode. Designed for high-performance scenarios (bullet hell, pixel explosions) where the full CCParticleSystem is too heavy. No plist files, no textured quads — just DrawDot/DrawFilledCircle calls against a pre-allocated particle array. Zero GC pressure during gameplay. Usage: var emitter = new CCParticleEmitterLight(128); emitter.OnUpdateParticle = (ref particle, dt) => particle.Velocity *= 1f - 0.4f * dt; // drag particle.Position += particle.Velocity * dt; ; parentNode.AddChild(emitter); emitter.Emit(position, 20, velocity, spread, colors);
Inheritance: System.Object → Cocos2D.CCNode → Cocos2D.CCDrawNode
Implements: Cocos2D.ICCSelectorProtocol, Cocos2D.ICCFocusable, Cocos2D.ICCTargetedTouchDelegate, Cocos2D.ICCStandardTouchDelegate, Cocos2D.ICCTouchDelegate, Cocos2D.ICCKeypadDelegate, Cocos2D.ICCKeyboardDelegate, Cocos2D.ICCRGBAProtocol, System.Collections.Generic.IComparer{Cocos2D.CCNode}
Constructors
CCParticleEmitterLight(int)
CCParticleEmitterLight(int)(System.Int32 maxParticles)Creates a lightweight particle emitter with a fixed maximum particle count.
Parameters:
maxParticles (System.Int32) - Maximum number of simultaneous particles.Example
Properties
Number of currently active particles.
Default drag applied to particle velocity each frame (0 = no drag, 1 = full stop). Only used when OnUpdateParticle is null.
Whether this emitter is currently active (has living particles).
Custom update callback. Called for each active particle every frame. If null, default behavior is applied (linear velocity, linear alpha fade).
Whether particles should use quadratic alpha fade (more natural) vs linear. Only used when OnUpdateParticle is null.
Methods
Emit(CCPoint, int, float, float, float, CCColor4F, float, float, float, float)
Emit(CCPoint, int, float, float, float, CCColor4F, float, float, float, float)(Cocos2D.CCPoint position, System.Int32 count, System.Single speed, System.Single spreadAngle, System.Single baseAngle, Cocos2D.CCColor4F color, System.Single life, System.Single size, System.Single speedVariance, System.Single lifeVariance)Emits particles from a position with the given parameters.
Parameters:
position (Cocos2D.CCPoint) - World position to emit from.count (System.Int32) - Number of particles to emit.speed (System.Single) - Base speed of emitted particles.spreadAngle (System.Single) - Spread angle in radians (MathHelper.TwoPi for full circle).baseAngle (System.Single) - Center angle of emission cone in radians.color (Cocos2D.CCColor4F) - Particle color.life (System.Single) - Particle lifetime in seconds.size (System.Single) - Particle render size (radius for DrawDot).speedVariance (System.Single) - Random variance applied to speed (0-1 range).lifeVariance (System.Single) - Random variance applied to lifetime (0-1 range).Example
Emit(CCPoint, int, float, float, float, CCColor4F[], float, float, float, float)
Emit(CCPoint, int, float, float, float, CCColor4F[], float, float, float, float)(Cocos2D.CCPoint position, System.Int32 count, System.Single speed, System.Single spreadAngle, System.Single baseAngle, Cocos2D.CCColor4F[] colors, System.Single life, System.Single size, System.Single speedVariance, System.Single lifeVariance)Emits particles with per-particle colors sampled from an array. Useful for explosions that match a sprite's pixel colors.
Parameters:
position (Cocos2D.CCPoint)count (System.Int32)speed (System.Single)spreadAngle (System.Single)baseAngle (System.Single)colors (Cocos2D.CCColor4F[])life (System.Single)size (System.Single)speedVariance (System.Single)lifeVariance (System.Single)Example
StopAll()
StopAll()()Stops all active particles immediately.
Example
UpdateParticles(float)
UpdateParticles(float)(System.Single dt)Updates all active particles and redraws. Call this once per frame.
Parameters:
dt (System.Single)Example