PixiJS Integration

PixiJS Integration Guide

Step-by-step guide to export SlotVFX effects and integrate them into your PixiJS v7 or v8 project. Works with any PixiJS setup — vanilla, React-Pixi, or game frameworks.

1 Export Your Project

In the SlotVFX editor, open the Export menu and choose PixiJS Bundle. This generates a ZIP containing everything you need.

project_name/
├── project_data.json        # Unified effect data
├── Particles/               # Particle textures (.png)
│   └── *.png
├── VFX/                     # VFX spritesheets
│   └── *_sheet.png
├── Scripts/
│   └── SlotFXPixiRuntime.js # Runtime engine
├── index.html               # Ready-to-run example
└── README.txt               # Quick reference

💡 Quick Test First

Use Quick Test (PixiJS) from the export menu to preview your effect before exporting. This renders the exact same data format, so if it looks right in Quick Test, it will look right in your game.

2 Add to Your Project

Copy the exported files into your project. Include SlotFXPixiRuntime.js as a script tag or import it as a module.

<!-- Include PixiJS (v7 or v8) -->
<script src="https://pixijs.download/v7.4.2/pixi.min.js"></script>

<!-- Include SlotVFX Runtime -->
<script src="Scripts/SlotFXPixiRuntime.js"></script>

Or if using a bundler (Webpack, Vite, etc.):

import { SlotFXPixiRuntime } from './Scripts/SlotFXPixiRuntime.js';

3 Initialize and Play

Create a PixiJS Application, load the project data, and start playback.

// Create PixiJS app
const app = new PIXI.Application({
    width: 800,
    height: 600,
    backgroundColor: 0x000000,
    antialias: true
});
document.body.appendChild(app.view);

// Load and play
const data = await fetch('project_data.json').then(r => r.json());
const runtime = new SlotFXPixiRuntime(app);
await runtime.load(data, 'Particles');
runtime.play();

💡 Asset Path

The second argument to load() is the base path for particle textures. If your textures are in a Particles/ folder relative to your HTML, pass 'Particles'.

4 Runtime Controls

The runtime exposes a full API for controlling playback, emitters, force fields, and more.

// Basic playback
runtime.play();
runtime.stop();
runtime.pause();           // Pause (keeps state)
runtime.resume();          // Resume from pause
runtime.seek(1.5);         // Jump to 1.5 seconds

// Speed and position
runtime.setTimeScale(0.5); // Half speed (slow-mo)
runtime.setPosition(400, 300); // Center the effect

// Timeline control
runtime.setTimelineLoop(true);      // Loop forever
runtime.setTimelineDuration(5.0);   // Override duration
runtime.getTimelineTime();          // Current time

5 Emitter Control

Access individual emitters by name or ID for fine-grained control.

// Get emitter by name
const emitter = runtime.getEmitter('Sparkles');

// Trigger a particle burst
runtime.triggerBurst('Sparkles', 50);

// Show/hide emitters
runtime.setEmitterVisible('Sparkles', false);

// Override emission rate
runtime.setEmitterEmissionRate('Sparkles', 200);

// Direct emitter access
emitter.burst(20);
emitter.reset();

6 State Machine

If your project defines states (idle, win, bonus, etc.), control them with triggers.

// Trigger transitions
runtime.trigger('start_bonus');    // idle → bonus
runtime.trigger('end_bonus');      // bonus → idle

// Force-set a state
runtime.setState('big_win_state_id');

// Query state
runtime.getCurrentState();         // state ID
runtime.getCurrentStateName();     // "Bonus Mode"
runtime.getAvailableTriggers();    // ['end_bonus']

💡 State Machine Tips

On state change, all entities reset to defaults, new state overrides are applied, and the timeline resets to t=0. States can override timelineLoop and timelineDuration independently.

7 VFX Spritesheets

Energy Beam and Lightning effects are exported as spritesheets and played automatically by the runtime.

// Access VFX players
for (const [id, player] of runtime.vfxPlayers) {
    player.play();
    player.stop();
    player.reset();
}

⚡ Performance Tips

Particle Count

Keep max particles under 500 per emitter for mobile. Use bursts instead of continuous emission when possible.

Texture Atlases

When using multiple particle textures, consider combining them into a single atlas to reduce draw calls. The runtime handles sprite frame lookups automatically.

Cleanup

Always call runtime.destroy() when removing effects from your scene to free GPU resources and stop the update loop.

⚠️ PixiJS Version

The runtime works with PixiJS v7 and v8. If using v8, note that app.view has been renamed to app.canvas. The runtime handles both automatically.

Ready to dive deeper?

Full API Reference → Cocos Guide →

Frequently Asked Questions

Quick answers about PixiJS setup

SlotVFX supports PixiJS v7 and v8. The runtime automatically detects your version and adapts accordingly.

Create a PIXI.Application, instantiate SlotFXPixiRuntime, load your exported project_data.json using runtime.load(config, texturesPath), then call runtime.play().

Full particle emission with all shapes, force fields, path following, curl noise, sprite sheet animation, color ramps, VFX spritesheet playback, Spine rendering, state machine, timeline animation, and z-index sorting.

Use the built-in object pooling, limit active particle count, use sprite sheets, disable unused force fields, and use WebGL2 for better batch rendering.