pixi-reels

API reference

Abstract Class: ReelPhase

pixi-reels


pixi-reels / index / ReelPhase

Defined in: spin/phases/ReelPhase.ts:157

Abstract base for reel spin phases.

Each phase represents one stage of the spin lifecycle: START → SPIN → ANTICIPATION → STOP.

Phases are entered and exited by SpinController, and can be skipped if marked as skippable and the user triggers skip/slam-stop.

A phase drives its reel through this.reel and reads its timing from this.speed. What the built-in phases call on the reel is the contract a custom phase may rely on too: placeStrip(), beginMotion(), notifySpinStart(), forceSpeed() and the public accessors. The two moments every stop phase has to express, landing and bouncing, are land and bounce, so a phase written from scratch never has to reach for the reel’s internals.

The built-in phases run a named list of steps through runSteps, which is what lets a game insert, replace or remove one step of a built-in without subclassing it (f.register('stop', StopPhase, { steps })). A custom phase may run its own steps the same way, or ignore the runner and drive the reel from onEnter / update as before.

Extended by#

Type Parameters#

Type ParameterDefault typeDescription
TConfigvoidPhase-specific configuration type.
TProfile extends SpeedProfileSpeedProfileThe speed profile this phase reads. Widen it when a phase carries its own timing on the profile (interface InstantProfile extends SpeedProfile { slideMs: number }): the manager hands every phase the profile instance the game registered, so the extra fields are there at run time, and the parameter is what lets this.speed see them.

Constructors#

Constructor#

new ReelPhase<TConfig = void, TProfile extends SpeedProfile = SpeedProfile>(reel: Reel, speed: TProfile): ReelPhase<TConfig, TProfile>;

Defined in: spin/phases/ReelPhase.ts:178

Parameters#

ParameterType
reelReel
speedTProfile

Returns#

ReelPhase<TConfig, TProfile>

Properties#

PropertyModifierTypeDefault valueDescriptionDefined in
_configprotectedTConfig | nullnullThe config run() was given, for ctx.config.spin/phases/ReelPhase.ts:174
_isActiveprotectedbooleanfalse-spin/phases/ReelPhase.ts:172
_reelprotectedReelundefined-spin/phases/ReelPhase.ts:169
_resolveprotected(() => void) | nullnull-spin/phases/ReelPhase.ts:171
_speedprotectedTProfileundefined-spin/phases/ReelPhase.ts:170
nameabstractstringundefined-spin/phases/ReelPhase.ts:158
quickenablereadonlybooleanfalseWhether a 'quicken' press may reach onSkip(ctx). A phase that declares it branches on ctx.mode there and completes itself when the natural end is reached. One that does not is left alone by a quicken (its cut steps are still skipped), so a phase written for slams only keeps working. The built-ins declare it.spin/phases/ReelPhase.ts:167
skippableabstractbooleanundefined-spin/phases/ReelPhase.ts:159

Accessors#

anticipated#

Get Signature#

get anticipated(): boolean;

Defined in: spin/phases/ReelPhase.ts:220

The reel ran an anticipation tease earlier in this spin.

Returns

boolean


context#

Get Signature#

get context(): PhaseCreateContext;

Defined in: spin/phases/ReelPhase.ts:215

How this phase was created: which reel, and what had already happened to it.

Returns

PhaseCreateContext


isActive#

Get Signature#

get isActive(): boolean;

Defined in: spin/phases/ReelPhase.ts:233

Returns

boolean


quickened#

Get Signature#

get quickened(): boolean;

Defined in: spin/phases/ReelPhase.ts:238

true once a 'quicken' press has reached this phase.

Returns

boolean


reel#

Get Signature#

get reel(): Reel;

Defined in: spin/phases/ReelPhase.ts:183

Returns

Reel


speed#

Get Signature#

get speed(): TProfile;

Defined in: spin/phases/ReelPhase.ts:192

The profile this phase runs on, as the game registered it. A 'quicken' press that names one swaps it. Read timing instead to get the phase’s own section folded in.

Returns

TProfile


timing#

Get Signature#

get timing(): TProfile;

Defined in: spin/phases/ReelPhase.ts:206

The profile with this phase’s own section folded into the flat fields: the profile first, then profile[phase], then that section’s whenAnticipated when the reel teased earlier in this spin.

Every field keeps its profile-wide name, so a phase reads this.timing.spinSpeed whether the game set spinSpeed at the top level or only inside start. A profile with no section for this phase returns the profile itself, unchanged.

Returns

TProfile

Methods#

_complete()#

protected _complete(): void;

Defined in: spin/phases/ReelPhase.ts:338

Call when the phase naturally completes.

Returns#

void


bounce()#

bounce(options?: BounceOptions): ReelBounce;

Defined in: spin/phases/ReelPhase.ts:585

Overshoot the reel in its direction of travel and settle it back, the classic landing bounce. Call it after land: the overshoot is measured from wherever the reel container rests right now.

Moving the container after a landing is not a plain tween. land() has just lifted every at-rest unmask symbol into a layer that does NOT inherit the reel’s offset, so for as long as the bounce runs the base carries those views along on every frame, and the settle lands them on the exact resting position rather than the tween’s last epsilon. That bookkeeping is why the bounce is a helper and not two lines of GSAP, and why a different bounce shape goes through options.animation rather than a raw tween of the container.

Defaults come from the phase’s profile; pass BounceOptions to bounce differently (a pressed reel that lands on a shorter bounce, say). A non-positive distance returns an already-settled bounce, so the caller’s done handling is the same either way.

Parameters#

ParameterType
optionsBounceOptions

Returns#

ReelBounce


defaultBounce()#

static defaultBounce(ctx: BounceContext): Animation;

Defined in: spin/phases/ReelPhase.ts:559

The built-in bounce: out by distance, back to base, half the time each.

Parameters#

ParameterType
ctxBounceContext

Returns#

Animation


forceComplete()#

forceComplete(ctx?: SkipContext<TProfile>): void;

Defined in: spin/phases/ReelPhase.ts:309

Slam this phase regardless of skippable: cancel the step in flight, onSkip(ctx), complete. What the controller’s slam path calls; ctx.mode is 'slam' there.

Parameters#

ParameterType
ctxSkipContext<TProfile>

Returns#

void


land()#

land(cells?: readonly number[]): void;

Defined in: spin/phases/ReelPhase.ts:547

Bring the reel to rest on the frame it is showing and announce the landing: the drive halts, the strip snaps to the cell grid, symbols are told the spin is over and then that they landed (which lifts unmask symbols above the mask and plays the landing animation), and the reel’s landing event fires, bridged to the set’s spin:reelLanding.

Place the frame first (this.reel.placeStrip(frame)), or let the spin-out carry it in as StopPhase does; this call does not choose the symbols. It is the whole of what StopPhase does between its spin-out and its bounce, and the only way a phase lands a reel.

Parameters#

ParameterTypeDescription
cells?readonly number[]Visible cells (0-indexed) whose symbols receive onReelLanded(). Omit for a strip landing, where every visible symbol landed; pass the cells that moved when only some did.

Returns#

void


onEnter()#

abstract protected onEnter(config: TConfig): void;

Defined in: spin/phases/ReelPhase.ts:320

Subclass: set up the phase (start tweens, set speed, etc).

Parameters#

ParameterType
configTConfig

Returns#

void


onSkip()#

abstract protected onSkip(ctx: SkipContext<TProfile>): void;

Defined in: spin/phases/ReelPhase.ts:335

Subclass: a skip press reached the phase. Branch on ctx.mode.

Under 'slam' this is the slam pose: the base has cancelled the step in flight; kill anything else and leave the reel where a natural finish would have; the base completes the phase after.

Under 'quicken' (only reached when quickenable) cut a wait, never the landing, and call _complete() yourself once the natural end is reached, right away if the slam pose already is that end. A phase on runSteps usually needs nothing here: its cut steps are skipped for it. ctx.payload is whatever the game attached to the press.

Parameters#

ParameterType
ctxSkipContext<TProfile>

Returns#

void


run()#

run(config: TConfig): Promise<void>;

Defined in: spin/phases/ReelPhase.ts:257

Enter the phase. Returns a promise that resolves when the phase is complete.

Parameters#

ParameterType
configTConfig

Returns#

Promise<void>


runSteps()#

protected runSteps(steps: readonly PhaseStep<StepContext<any, any, StepTiming>>[]): void;

Defined in: spin/phases/ReelPhase.ts:356

Run steps in order and complete the phase after the last one. Each step’s result is waited on (a tween or timeline, a promise, a cancellable such as bounce’s, or nothing). A slam cancels the step in flight; a quicken skips the steps marked cut, in flight or upcoming. Call tickSteps from update() so ctx.until() can watch the reel.

Parameters#

ParameterType
stepsreadonly PhaseStep<StepContext<any, any, StepTiming>>[]

Returns#

void


skip()#

skip(ctx?: SkipContext<TProfile>): void;

Defined in: spin/phases/ReelPhase.ts:289

A skip press reached this phase.

'slam' (the default): if the phase is skippable, the step in flight is cancelled, onSkip(ctx) runs and the phase completes at once; the controller then places the reel.

'quicken': the phase is asked to reach its natural end sooner without changing what it looks like. A profile named on the press replaces speed first. Then, if the phase is quickenable, onSkip(ctx) runs; then every cut step is skipped, the one in flight included. A phase that is neither quickenable nor running steps is left to run its course, and still lands. skippable is not consulted, since nothing is forced.

Parameters#

ParameterType
ctxSkipContext<TProfile>

Returns#

void


tickSteps()#

protected tickSteps(): void;

Defined in: spin/phases/ReelPhase.ts:397

Feed ctx.until() from the phase’s update(): every pending predicate is checked and the steps waiting on a true one resume.

Returns#

void


update()#

abstract update(deltaMs: number): void;

Defined in: spin/phases/ReelPhase.ts:317

Called each frame while the phase is active.

Parameters#

ParameterType
deltaMsnumber

Returns#

void