Skip to main content

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):
This will create a light halo behind all sprites with:
  • 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

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)
The component is rendered behind the sprite (using 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
For best performance when using multiple light halos:
  • Use lower radiusVariation values for subtler effects
  • Reduce baseOpacity if 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