Overview
The main parts of pixi-reels and how they are wired together.
A slot machine looks simple from the outside: press a button, five columns blur, five columns stop, you see a grid. Inside a real game that moment is a surprising amount of coordination. Something has to fetch the result from a server while the reels are already moving, hand each column the exact symbols it must land on, stop them one after another with a satisfying bounce, let one column hesitate for drama, and survive a player who taps the button twenty times a second. pixi-reels is that machinery, packaged so you can build the game around it instead of building it again.
Three rings
It helps to picture the library as three rings around your game. The innermost ring is the builder: a fluent object that collects your configuration and, in one build() call, checks it and constructs everything. The middle ring is the reel set: the container that owns the reels, the spin controller, the speed profiles and the win spotlight. The outer ring is optional tooling, testing and debug, that attaches from the outside and never ships in your bundle unless you import it.
Figure 1 is the middle ring after build() returns. The boxes inside the ReelSet are its subsystems; each one has its own page in this tour.
- SpinController is the conductor. It walks each reel through its phases (start, spin, maybe anticipation, stop), holds every reel back until your result has arrived, and turns a skip press into a slam or a quicken. It never draws and never chooses an outcome.
- SpeedManager holds named timing profiles, normal, turbo and super turbo out of the box, and lets you tune any phase at runtime.
- FrameBuilder turns your result grid into the exact list of symbols each reel will show, buffers included, before the reel starts stopping.
- SymbolFactory hands out symbol instances from a pool, one pool per symbol id, so a five-second spin allocates nothing.
- SymbolSpotlight is the win presentation primitive: dim the losers, lift the winners above the mask, play their animation.
- EventEmitter is how the set talks back. Fifty-nine typed events, from
spin:starttopin:expired.
What a reel is
The word "reel" usually means a column on screen. In pixi-reels a reel is a strip: an array of symbols that is longer than the window you see. The extra symbols sit just outside the visible area, above and below it, so there is always something ready to scroll in. The window itself is a mask on the viewport. Figure 2 shows the five strips under that mask.
Each strip carries three small helpers. ReelAxis knows which screen axis the strip travels on and in which direction, so the same code runs a vertical, horizontal or reversed reel. ReelMotion owns the position of every symbol and derives it from the array index on every frame, which is why reels never drift. StopSequencer is the short queue of symbols the reel must land on, handed out one at a time as symbols wrap around. The motion page walks through one frame of all three.
Things that attach from outside
Two subpaths exist so you can look inside without shipping the tools. pixi-reels/testing swaps exactly two things, the Pixi ticker and the symbol art, and leaves everything else real, which is why a whole spin can run in Node in a few milliseconds. pixi-reels/debug draws what the engine knows (cells, buffers, axes, a phase timeline) onto the canvas, and enableDebug() in the main entry exposes the same facts as JSON for anyone, human or agent, who cannot see a canvas.
One spin, end to end
Here is the story the rest of this tour tells in detail. You call spin(). Each reel starts a little after the previous one, so the kickoff looks staggered. Meanwhile your code asks the server for the outcome and calls setResult() with the grid. The controller waits until every reel is actually spinning and until each has spun for a minimum time, then lets them stop one by one. As a stopping reel scrolls, the symbols it must land on are swapped in at the top edge, one per wrap, until the last one is in place; the reel snaps to the grid and bounces. When the last reel has bounced, the promise from spin() resolves with the grid and the set emits spin:complete.
If the player presses skip, the controller either slams (every reel lands on its result this frame) or quickens (the delays are cut, the landing still plays), depending on what you asked for. If a reel was set up to tease, it slows down and holds before it stops, and you can protect that tease from the first skip press. All of that is covered on the spin lifecycle, timeline, skipping and anticipation pages.
Where the code lives
You rarely need to open these files, but it helps to know the map when a stack trace points into the library.
core/the set, the builder, one reel and its motion, axis, curve and viewportspin/the controller, the phases and their steps, the spinning modessymbols/the symbol base class and its sprite, animated, Spine and card flavours, plus the registry and factoryframe/how a result grid becomes a strip of symbolsconfig/types, defaults, the speed presetsspeed/,spotlight/,wins/timing profiles and win presentationcascade/,board/,pins/tumble physics, boards and Hold & Win, sticky cellsevents/,utils/the typed emitter, the ticker wrapper, gsap plumbing, noticesdebug/,testing/the two subpaths
BlurSpriteSymbol.tsa sprite symbol that swaps to a motion-blur texture while spinningCoinSymbol.tsa coin drawn with Graphics, for Hold & Win demosholdAndWinFx.tscoin waves and collect flightsprototypeSpriteLoader.tsthe open-licensed symbol atlas the demos usespineSets.tsthe bundled Spine sets behind one interface
cheats.tsforced results for demos and testsseededRng.tsa tiny seeded random number generator
The recipe runtime and the cheats package are reference code, not library API. They live outside the package on purpose so you copy what you need into your own game and own it.
Which way the imports point
One rule keeps the library easy to reason about and lets the testing subpath be dropped from your bundle: imports only ever point down the stack in figure 4. The types and the event emitter know nothing about reels; reels know nothing about the controller; the controller knows nothing about the set that owns it.
Read on in order, or jump to the page that answers your question. Every page opens with the idea in plain words, then shows it, then names the code.