pixi-reels

StopPhase

pixi-reels


pixi-reels / index / StopPhase

Class: StopPhase

Defined in: spin/phases/StopPhase.ts:48

Stops the reel on the target frame.

Steps, in order:

  1. delay: wait the staggered delay. Cut by a quicken.
  2. spinOut: keep spinning at full speed with isStopping flagged. The target frame is loaded into the StopSequencer; each wrap event at the top of the reel pulls the next frame symbol. so targets arrive in the visible area naturally, carrying the full momentum of the spin. Ends when the sequencer is exhausted.
  3. land: snap to grid, tell the symbols, raise the landing.
  4. bounce: overshoot by bounceDistance and settle back over bounceDuration.

Extends#

Constructors#

Constructor#

new StopPhase(
   reel: Reel, 
   speed: SpeedProfile, 
   options?: StopPhaseOptions
): StopPhase;

Defined in: spin/phases/StopPhase.ts:57

Parameters#

ParameterType
reelReel
speedSpeedProfile
optionsStopPhaseOptions

Returns#

StopPhase

Overrides#

ReelPhase.constructor

Properties#

PropertyModifierTypeDefault valueDescriptionOverridesInherited fromDefined in
_baseYprotectednumber0---spin/phases/StopPhase.ts:55
_configprotectedStopPhaseConfig | nullnullThe config run() was given, for ctx.config.-ReelPhase._configspin/phases/ReelPhase.ts:132
_isActiveprotectedbooleanfalse--ReelPhase._isActivespin/phases/ReelPhase.ts:130
_optionsreadonlyStopPhaseOptionsundefined---spin/phases/StopPhase.ts:53
_reelprotectedReelundefined--ReelPhase._reelspin/phases/ReelPhase.ts:127
_resolveprotected(() => void) | nullnull--ReelPhase._resolvespin/phases/ReelPhase.ts:129
_speedprotectedSpeedProfileundefined--ReelPhase._speedspin/phases/ReelPhase.ts:128
_stageprotected"delay" | "landed" | "spinning" | "done"'delay'---spin/phases/StopPhase.ts:54
namereadonly"stop"'stop'-ReelPhase.name-spin/phases/StopPhase.ts:49
quickenablereadonlytruetrueWhether 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.ReelPhase.quickenable-spin/phases/StopPhase.ts:51
skippablereadonlytruetrue-ReelPhase.skippable-spin/phases/StopPhase.ts:50

Accessors#

isActive#

Get Signature#

get isActive(): boolean;

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

Returns

boolean

Inherited from#

ReelPhase.isActive


quickened#

Get Signature#

get quickened(): boolean;

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

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

Returns

boolean

Inherited from#

ReelPhase.quickened


reel#

Get Signature#

get reel(): Reel;

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

Returns

Reel

Inherited from#

ReelPhase.reel


speed#

Get Signature#

get speed(): TProfile;

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

The profile this phase runs on. A 'quicken' press that names one swaps it.

Returns

TProfile

Inherited from#

ReelPhase.speed

Methods#

_beginSpinOut()#

protected _beginSpinOut(): void;

Defined in: spin/phases/StopPhase.ts:87

Returns#

void


_complete()#

protected _complete(): void;

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

Call when the phase naturally completes.

Returns#

void

Inherited from#

ReelPhase._complete


bounce()#

bounce(options?: BounceOptions): ReelBounce;

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

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

Inherited from#

ReelPhase.bounce


defaultBounce()#

static defaultBounce(ctx: BounceContext): Animation;

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

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

Parameters#

ParameterType
ctxBounceContext

Returns#

Animation

Inherited from#

ReelPhase.defaultBounce


defaultSteps()#

defaultSteps(): PhaseStep<StopStepContext>[];

Defined in: spin/phases/StopPhase.ts:63

The built-in list. A subclass overrides this to change the flow; a game edits it through options.steps.

Returns#

PhaseStep<StopStepContext>[]


forceComplete()#

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

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

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<SpeedProfile>

Returns#

void

Inherited from#

ReelPhase.forceComplete


land()#

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

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

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

Inherited from#

ReelPhase.land


onEnter()#

protected onEnter(config: StopPhaseConfig): void;

Defined in: spin/phases/StopPhase.ts:80

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

Parameters#

ParameterType
configStopPhaseConfig

Returns#

void

Overrides#

ReelPhase.onEnter


onSkip()#

protected onSkip(ctx?: SkipContext): void;

Defined in: spin/phases/StopPhase.ts:136

Slam: rest on the frame, landed. Quicken: nothing to do here, the runner skips the delay step and the spin-out starts at once; a profile the press named has been swapped in and shapes the spin-out and the bounce still to come.

Parameters#

ParameterType
ctxSkipContext

Returns#

void

Overrides#

ReelPhase.onSkip


run()#

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

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

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

Parameters#

ParameterType
configStopPhaseConfig

Returns#

Promise<void>

Inherited from#

ReelPhase.run


runSteps()#

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

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

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>>[]

Returns#

void

Inherited from#

ReelPhase.runSteps


skip()#

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

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

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<SpeedProfile>

Returns#

void

Inherited from#

ReelPhase.skip


tickSteps()#

protected tickSteps(): void;

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

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

Returns#

void

Inherited from#

ReelPhase.tickSteps


update()#

update(_deltaMs: number): void;

Defined in: spin/phases/StopPhase.ts:126

Called each frame while the phase is active.

Parameters#

ParameterType
_deltaMsnumber

Returns#

void

Overrides#

ReelPhase.update