pixi-reels
Reference
Timing

Speed profiles

The object that holds a spin's timing, such as stagger, speed and bounce, and how to tune it.

Ask a player what "turbo" means and they will tell you: the columns start together instead of one by one, they do not hang around, they drop together, and the bounce is a quick snap instead of a lazy settle. Every one of those is a number: how long each reel waits before it starts, how fast it spins, how long it must spin at minimum, how long each reel waits before stopping, how long a tease holds, how far and how long the bounce is. A speed profile is the object that holds all of those numbers in one place, so "turbo" is a different object rather than a scattering of if-statements.

A profile has two layers. The flat fields are the handful of numbers above, enough for most games and all that the presets use. On top of them, optional phase sections override a number for one phase only, set a timing for one step, and carry a whenAnticipated variant that only applies to reels that teased. The speed manager holds the profiles at runtime and lets you tune a phase without replacing the profile. ADR 021 (docs/adr/021-phase-sections-on-speed-profiles.md) is the design record.

The shape of a profile

Figure 1 is one profile laid out as a diagram. The flat fields sit across the top. Below them are eight optional sections, one per phase name; most profiles have none, and the presets have none. The stop section is highlighted because figure 2 opens it up.

SpeedProfileSpeedProfileBase & PhaseSections (types.ts:537)SpeedProfileBasename, spinDelay, spinSpeed, stopDelay, anticipationDelay,bounceDistance, bounceDuration, the ease and duration options, tumblePhaseSectionsall optional; games add phases by declaration mergingstartspinanticipationstopadjustcascade:fallcascade:placecascade:dropIn
The shape of one profile. The flat SpeedProfileBase fields sit next to eight optional phase sections, one per phase name. The stop section is opened up in the next figure.

Figure 2 is the stop section opened up. A section can do three things: set any of the flat timing fields again, for this phase only; give each of the phase's steps its own timing (an ease and a duration); and carry a whenAnticipated block that does both again, but only for a reel that teased to its end. Notice that whenAnticipated cannot contain another whenAnticipated.

stop: PhaseSection<StopSteps>one section, opened upPhaseTimingany base field again,minus name and tumblestepsdelay, spinOut, land, bounceStepTiming | StepTiming[]whenAnticipatedtiming + steps again,cannot nestStepTiming{ ease?: string, duration?: number }; built-in steps read step[0]
One section opened up: stop is a PhaseSection<StopSteps>. A section may re-set any timing field, give each step one or more StepTiming entries, and carry a whenAnticipated variant of both.
codethe literal field or type
sectionthe one phase section the second figure opens up
phase namekeys of PhaseProfiles

In code, a stop section with every part in use looks like this. It removes the stop stagger, gives the bounce a springier ease, and makes the bounce slower on a reel that teased:

stop: {
  stopDelay: 0,
  steps: { bounce: { duration: 400, ease: 'back.out' } },
  whenAnticipated: { steps: { bounce: { duration: 900 } } },
}

The flat fields

The flat fields are what the player feels directly. spinDelay and stopDelay are the staggers between reel starts and reel stops; spinSpeed is how fast the strip moves; minimumSpinTime is how long each reel must blur before it may stop; anticipationDelay is how long a tease holds; bounceDistance and bounceDuration shape the landing. Alongside them are the optional eases and durations for the acceleration and the bounce, a name, and a tumble block: a per-speed TumbleConfig, deep-merged over the builder's base when a cascade phase enters, so a turbo profile can shorten fall.duration and dropIn.duration (both at 0 snaps the cascade). All fields are readonly. decelerationEase is deprecated and no phase reads it; the presets still carry a value for compatibility. One hedge from reading the code: spinSpeed is documented as pixels per frame, while StandardMode computes slotPitch * speed * deltaMs / 1000 with a half-cell cap per frame, so treat the unit note with care and see the motion page.

The presets

The three presets, field by field; the timeline page shows what the NORMAL column produces in milliseconds.

KeyNORMALTURBOSUPER_TURBO
name'normal''turbo''superTurbo'
spinDelay100300
spinSpeed305080
stopDelay14000
anticipationDelay4502500
bounceDistance564214
bounceDuration600200120
bounceEaseunset (power1.out)unset (power1.out)unset (power1.out)
accelerationEasepower2.inpower2.inpower1.in
decelerationEasepower2.out (unused)power2.out (unused)power1.out (unused)
accelerationDuration30020050
minimumSpinTime500300100
tumblenonenonenone
phase sectionsnonenonenone

Three things fall out of the numbers. TURBO still teases, because its hold is 250 ms; SUPER_TURBO does not, unless setAnticipation is given a positive duration. All three have a bounceDistance above zero, so all three play the small backward pull at the start of a spin. And none of them has a phase section or a tumble block, so every preset resolves to its flat fields alone. The bounce values are tuned for symbols of about 120 to 200 px.

Phase sections and their types

Sections are typed so you cannot misspell a step. PhaseTiming is every flat field except name and tumble, all optional. A PhaseSection is that timing plus steps, a map from step name to one StepTiming or a list of them, plus whenAnticipated, the same body without another whenAnticipated inside. The PhaseProfiles registry names the eight phases in figure 1, and three interfaces list the step names: StartSteps (delay, launch, pull, accelerate, announce), AnticipationSteps (tease) and StopSteps (delay, spinOut, land, bounce). A game that adds its own phase or step extends them with declaration merging and gets typed sections for free:

declare module 'pixi-reels' {
  interface PhaseProfiles { 'my:flourish': PhaseSection<{ sparkle: StepTiming }> }
  interface StopSteps { settle: StepTiming }
}

Which layer wins

With four places a number can come from, the question is which one wins. Figure 3 stacks them. Read the left column bottom to top: the flat field is the floor, the phase section overrides it, whenAnticipated overrides that but only for a reel that teased, and a runtime tune sits on top. The right column names the three functions that do the merging.

speed.tune(phase, section)runtime layer, merged in firstwhenAnticipatedonly if context.anticipatedprofile[phase]PhaseTiming fields and stepsflat fieldthe profile itselfoverridesresolvePhaseProfile(){ ...p, ...timingOf(section),...timingOf(whenAnticipated) }resolveStepTiming()the step list with whenAnticipatedmerged over it, position by positionmergeSection / tuneProfileflat fields replace, steps andwhenAnticipated merge by position
How a number is resolved for one phase of one reel: phase.timing is resolvePhaseProfile(speed, phase, context.anticipated). Later layers override earlier ones; the tune is merged into the section before resolution, so a tuned whenAnticipated still only reaches reels that teased to the end.

A new phase asks for its timing with resolvePhaseProfile(profile, phase, anticipated), which spreads the profile, then the section's timing fields, then the whenAnticipated fields if the reel teased. With no section it returns the same profile object, so a plain preset allocates nothing per phase. The spread drops steps, whenAnticipated and any undefined value, so a section cannot blank out a field the profile set. resolveStepTiming does the same for one step, merging the whenAnticipated entries over the step's list position by position; that list is ctx.step, and the built-in steps read step[0].

Tunes use the same rule: mergeSection folds one section over another (flat fields replace, step lists merge by position) and tuneProfile uses it to fold each runtime tune into the matching section before anything is resolved. ADR 021 states the order as flat field, section, whenAnticipated, tune; merging the tune first gives the same answer and keeps a tuned whenAnticipated restricted to reels that teased. configuredStepNames backs the one-time warning for a step name the phase does not have.

Which step reads which number

Figure 4 maps which number reaches which start and spin step. The one to notice is start.steps.delay.duration: a step-level duration on the delay replaces the per-reel stagger rather than adding to it, so setting it gives every reel the same delay and the staircase disappears. Launch and announce read nothing.

spinDelayx stagger indexstart.steps.delay.durationreplaces the staggerpull defaults50 ms, power1.out, speed -2accelerationDuration / Ease300 ms, power2.inspinSpeedtarget of accelerateminimumSpinTime500 msstart.delaycut stepstart.pullonly if bounceDistance > 0start.accelerateto spinSpeedspin (wait)minimum, from spin entry
What the start and spin steps read. A step-level duration in start.steps.delay replaces the per-reel stagger, it is not added to it; launch and announce read nothing.

Figure 5 maps the tease and stop steps. The same replacement rule applies to stop.steps.delay.duration and the stop stagger. Spin-out and land read nothing from the profile: how long the spin-out takes is down to how many symbols must wrap and how fast the reel is going.

anticipationDelaythe hold; step.duration winsstopDelayx stagger indexstop.steps.delay.durationreplaces the stop staggerbounceDistance / Duration / Ease22 px, 220 ms, power1.outanticipation.teasecut stepstop.delaycut stepstop.bouncetwo legs
What the tease and stop steps read. stop.steps.delay.duration replaces the stop stagger the same way; spinOut and land read nothing from the profile.

The exact lookup each step performs, for when you need to know which of two settings wins.

StepReads, first match wins
start.delaystep[0].duration, else config.delay (the stagger, _staggerIndex(i) * spinDelay), else 0
start.pullexists only when the resolved bounceDistance > 0; step[0].duration else 50, step[0].ease else power1.out
start.acceleratestep[0].duration, else accelerationDuration, else 300; step[0].ease, else accelerationEase, else power2.in; targets spinSpeed
spinconfig.minimumSpinTime (from setMinimumSpinTime), else timing.minimumSpinTime, else 500
anticipation.teaseconfig.duration (from setAnticipation), else step[0].duration, else anticipationDelay
stop.delaystep[0].duration, else config.delay (from _stopDelayFor), else 0
stop.bouncestep.ease and step.duration, else bounceEase (power1.out), bounceDuration; distance is bounceDistance

The speed manager

The speed manager, reached as reelSet.speed, owns the named profiles, knows which is active, and layers tunes over it. What it does not do matters as much as what it does.

API
  • new SpeedManager(profiles: Map, initialSpeed): throws on an unknown initial name
  • active: the active profile with tunes merged in, cached in _tuned
  • activeName
  • set(name): returns { previous, current }, throws on an unknown name
  • tune(phase, section): layers over whichever profile is active and survives set()
  • clearTune(phase?): one phase or all
  • addProfile(name, profile), getProfile(name), profileNames
What it does not do
  • It emits nothing. speed:changed(current, previous) comes from ReelSet.setSpeed, which also calls notifyManualSpeedChange() on the controller.
  • It does not affect a running spin. spin() reads active once into _activeSpinSpeed and every phase of that spin gets the same object, so a set() or tune() takes effect on the next spin.
  • It does not know about skips. The round-ending skip boost calls set() directly, which is why that boost emits skip:boosted and not speed:changed, and why the restore on the next spin() is silent. A setSpeed() in between cancels the restore.

A tune is for a feature that wants a different feel for a while, say a free-spins round with a softer bounce, without registering a whole profile. It sticks to whichever profile is active:

reelSet.speed.tune('stop', { steps: { bounce: { duration: 900 } } }); // next spin, and after setSpeed('turbo') too
reelSet.setSpeed('turbo');            // emits speed:changed; the tune above still applies
reelSet.speed.clearTune('stop');

Defaults

The fallbacks when neither the profile nor a section sets a field.

SettingDefaultRead by
initialSpeed'normal'ReelSetBuilder via DEFAULTS
bounceEase'power1.out'ReelPhase.bounce
accelerationEase'power2.in'StartPhase accelerate
accelerationDuration300StartPhase accelerate
minimumSpinTime500SpinPhase
pull duration / ease / speed50 ms / 'power1.out' / -2StartPhase pull
curve segment ease'power2.inOut'AnticipationPhase
tumble fall300 ms, 'sine.in', cellStagger 0CascadeFallPhase, overridable per profile
tumble dropIn600 ms, 'power2.out', cellStagger 60, distance 'perHole'CascadeDropInPhase, overridable per profile
setDropOrder stepmax(active.stopDelay, 150)ReelSet.setDropOrder
Where this lives
  • packages/pixi-reels/src/config/types.ts: SpeedProfileBase, PhaseTiming, StepTiming, PhaseSection, PhaseProfiles, the step-name interfaces
  • packages/pixi-reels/src/config/phaseProfile.ts: resolvePhaseProfile, resolveStepTiming, mergeSection, mergeBody, tuneProfile, configuredStepNames
  • packages/pixi-reels/src/config/SpeedPresets.ts: NORMAL, TURBO, SUPER_TURBO
  • packages/pixi-reels/src/speed/SpeedManager.ts; ReelSet.setSpeed in packages/pixi-reels/src/core/ReelSet.ts
  • docs/adr/021-phase-sections-on-speed-profiles.md. Guide: speed modes. Recipes: feel. Related: a spin in milliseconds, anticipation