Light Halo Component
The Light Halo component creates a beautiful animated light effect that pulses and moves around sprites. It’s perfect for adding atmospheric lighting effects, magical auras, or ambient glow to characters and objects in your game.Overview
The Light Halo component uses a radial gradient with blur effects to simulate realistic light diffusion. It features:- Organic pulsing animation - Uses multiple sine waves for natural breathing effects
- Opacity variations - Smooth fade in/out with subtle flicker (candle-like effect)
- Customizable appearance - Configurable size, color, opacity, and animation speeds
- Reactive props - Supports both static and dynamic configuration based on sprite state
Basic Usage
Import the Component
First, import the LightHalo component from the prebuilt components:Simple Configuration with Defaults
Use the component with default settings (warm yellow-white light):- Base radius: 30 pixels
- Warm yellow-white color (0xffffaa)
- Smooth pulsing and fading animations
Configuration Options
All props are optional and have sensible defaults. You can customize any aspect of the light halo:Available Props
| Prop | Type | Default | Description |
|---|---|---|---|
baseRadius | number | 30 | Base radius of the light halo in pixels |
radiusVariation | number | 10 | Pulse variation range (halo pulses between baseRadius ± radiusVariation) |
baseOpacity | number | 0.6 | Base opacity of the light halo (0 to 1) |
opacityVariation | number | 0.3 | Opacity fade range (halo fades between baseOpacity ± opacityVariation) |
sizeSpeed | number | 0.002 | Animation speed for size pulsing (higher = faster) |
opacitySpeed | number | 0.003 | Animation speed for opacity fading (higher = faster) |
lightColor | number | 0xffffaa | Color of the light halo (hex value, warm yellow-white by default) |
Static Props Configuration
Configure the component with static values for all sprites:Dynamic Props Configuration
Use a function to compute props based on sprite state. The function receives the sprite object as a parameter and can access reactive properties:Color Examples
Here are some common color values you can use:Examples
Example 1: Subtle Ambient Light
A gentle, barely visible light for atmospheric effect:Example 2: Intense Magical Aura
A vibrant, pulsing magical aura:Example 3: Level-Based Dynamic Light
Light intensity increases with character level:Example 4: Conditional Light Based on State
Only show light when sprite has a certain state:Positioning
The Light Halo is automatically centered on the sprite by default. It uses the sprite’s hitbox to calculate the center position:- X Position:
hitbox.w / 2(center horizontally) - Y Position:
hitbox.h / 2(center vertically)
componentsBehind), so it appears as a background glow effect.
Performance Considerations
- The component uses efficient blur filters that are created once and reused
- Animation calculations are optimized using computed signals
- The drawing function only renders when opacity and radius are greater than 0
- Use lower
radiusVariationvalues for subtler effects - Reduce
baseOpacityif you don’t need bright lights - Consider using dynamic props to conditionally disable lights when not needed
Technical Details
Animation Algorithm
The component uses a sophisticated animation system:- Size Animation: Combines two sine waves with different frequencies for organic, less predictable pulsing
- Opacity Animation: Main breathing cycle with a subtle high-frequency flicker for realistic candle-like effects
- Blur Effect: Uses PixiJS BlurFilter with additive blend mode for realistic light diffusion
Reactive System
All props are reactive signals, meaning:- Static props are automatically converted to signals
- Dynamic props (functions) can access reactive sprite properties
- Changes to props automatically update the visual effect in real-time
See Also
- Sprite Components Guide - General guide on using sprite components
- CanvasEngine Reactive Programming - Understanding signals and reactivity