How-to
Add a symbol
Adding a new reel symbol to a slotplate project.
Short version
/add-symbol Watermelon (In Claude Code. The slash command does the steps below.)
Long version
- Add the texture. Drop the sprite in
public/assets/symbols/watermelon.png, or add it to your TexturePacker atlas. - Register in the asset bundle. In
composition.ts, add the alias to the asset bundle loaded before the main scene mounts. - Create the symbol class.
src/view/symbols/WatermelonSymbol.ts:
Subclassexport class WatermelonSymbol extends SpriteReelSymbol { constructor() { super('watermelon', Texture.from('watermelon')); } }SpriteReelSymbolonly if you need custom win animation, particles, or sub-sprites. For a simple sprite, reuse the base class directly from the factory. - Register in the factory.
SymbolFactorypicks a renderer per id. Add{ id: 'watermelon', renderer: 'sprite', textureAlias: 'watermelon' }to its definitions. - Add the id to
gameConfig.ts. ThesymbolIdsarray is the whitelist of what the server is allowed to send. An id not in this list means the factory throws loud — which is intentional. - Test it.
tests/view/WatermelonSymbol.test.ts— assert the lifecycle (activate, resize, playWin, dispose) works without throwing. - Run:
pnpm typecheck && pnpm test && pnpm lint.
If it's a Spine symbol
Use SpineReelSymbol instead. See the
Spine symbols guide for the peer-dep install, the
SymbolAnimationPlayer wiring, and the per-symbol animation config.
SymbolFactory picks per-id, so you can mix sprite and Spine symbols
in the same game.
Anti-patterns
- Importing pixi-reels or pixi.js outside
view/orpresenters/— lint error. - Putting payout info on the symbol. The client doesn't know payouts.
- Calling
setTimeoutfor the win pulse. Usegsap.to(this.scale, ...). - Scattering layout logic across constructor +
onActivate+resize. Put it inresize; it runs on every swap anyway.