AnticipationPhase
pixi-reels / index / AnticipationPhase
Class: AnticipationPhase
Defined in: spin/phases/AnticipationPhase.ts:85
Anticipation phase: the tease before a reel stops.
Two shapes, picked by the config:
Legacy (no curve). Decelerates to a fraction of spin speed over the
first 35% of the hold with power2.out, then sits there for the remaining
65%. Unchanged from 2.3 and still the default, so existing games look
identical.
Curve. Plays config.curve leg by leg: ease the speed to each segment’s
target, hold, move on. Segments may ask for MORE than spin speed, so a
surge-then-crawl tease is expressible. Segment eases default to
power2.inOut rather than power2.out, because an ease-out on a speed value
puts peak deceleration on the first frame - a step in acceleration, which is
what makes the legacy tease read as a setting change rather than as the reel
slowing down.
Travel anchor. With config.cells, the FINAL leg holds until the reel
has covered that many symbol pitches instead of for its scripted hold, so
the end of the tease is cut to symbols going past the window rather than to
a clock. Earlier legs always play in full: a travel target that could cut
the curve short mid-surge would silently delete legs the caller wrote. A
reel that comes to rest can never reach a travel target, so duration still
runs as the backstop on that final leg.
Either way the controller runs StopPhase with preserveSpeed: true
afterwards, so the speed the tease ends on carries into the spin-out and the
reel crawls onto its landing frame instead of re-accelerating.
Under the 'drive' motion model the phase assigns reel.targetSpeed per
segment and waits for the reel to arrive, letting the drive’s acceleration
bounds shape every transition instead of an ease.
Extends#
Constructors#
Constructor#
new AnticipationPhase(
reel: Reel,
speed: SpeedProfile,
options?: AnticipationPhaseOptions
): AnticipationPhase;
Defined in: spin/phases/AnticipationPhase.ts:117
Parameters#
| Parameter | Type |
|---|---|
reel | Reel |
speed | SpeedProfile |
options | AnticipationPhaseOptions |
Returns#
AnticipationPhase
Overrides#
Properties#
| Property | Modifier | Type | Default value | Description | Overrides | Inherited from | Defined in |
|---|---|---|---|---|---|---|---|
_backstopMs | protected | number | 0 | Backstop in ms for a travel-anchored final leg: a reel that comes to rest can never reach a cell target, and a tease that never ends is a hung spin. | - | - | spin/phases/AnticipationPhase.ts:113 |
_cells | protected | number | null | null | Travel target in cells, or null when this tease is time-anchored. | - | - | spin/phases/AnticipationPhase.ts:99 |
_config | protected | | AnticipationPhaseConfig | null | null | The config run() was given, for ctx.config. | - | ReelPhase._config | spin/phases/ReelPhase.ts:132 |
_delayed | protected | Tween | null | null | - | - | - | spin/phases/AnticipationPhase.ts:92 |
_events | protected | | EventEmitter<ReelSetEvents> | null | null | - | - | - | spin/phases/AnticipationPhase.ts:114 |
_finishTease | protected | (() => void) | null | null | Resolves the tease step. null outside a tease. | - | - | spin/phases/AnticipationPhase.ts:94 |
_isActive | protected | boolean | false | - | - | ReelPhase._isActive | spin/phases/ReelPhase.ts:130 |
_options | readonly | AnticipationPhaseOptions | undefined | - | - | - | spin/phases/AnticipationPhase.ts:90 |
_reel | protected | Reel | undefined | - | - | ReelPhase._reel | spin/phases/ReelPhase.ts:127 |
_reelIndex | protected | number | -1 | - | - | - | spin/phases/AnticipationPhase.ts:115 |
_resolve | protected | (() => void) | null | null | - | - | ReelPhase._resolve | spin/phases/ReelPhase.ts:129 |
_segmentIndex | protected | number | 0 | - | - | - | spin/phases/AnticipationPhase.ts:108 |
_segments | protected | AnticipationSegment[] | [] | Curve legs still to play, when driving segments by hand. | - | - | spin/phases/AnticipationPhase.ts:107 |
_speed | protected | SpeedProfile | undefined | - | - | ReelPhase._speed | spin/phases/ReelPhase.ts:128 |
_travelArmed | protected | boolean | false | True once the odometer is being watched. A curve arms it only on its FINAL leg, so a fast early segment cannot eat the travel budget and end the tease before the legs the caller wrote have played. | - | - | spin/phases/AnticipationPhase.ts:105 |
_travelMark | protected | number | 0 | Odometer reading (in cells) the travel target is measured from. | - | - | spin/phases/AnticipationPhase.ts:97 |
_tween | protected | Timeline | null | null | - | - | - | spin/phases/AnticipationPhase.ts:91 |
name | readonly | "anticipation" | 'anticipation' | - | ReelPhase.name | - | spin/phases/AnticipationPhase.ts:86 |
quickenable | readonly | true | true | Whether 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/AnticipationPhase.ts:88 |
skippable | readonly | true | true | - | ReelPhase.skippable | - | spin/phases/AnticipationPhase.ts:87 |
Accessors#
isActive#
Get Signature#
get isActive(): boolean;
Defined in: spin/phases/ReelPhase.ts:149
Returns
boolean
Inherited from#
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#
reel#
Get Signature#
get reel(): Reel;
Defined in: spin/phases/ReelPhase.ts:140
Returns
Inherited from#
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#
Methods#
_advance()#
protected _advance(): void;
Defined in: spin/phases/AnticipationPhase.ts:284
Returns#
void
_awaitTravel()#
protected _awaitTravel(backstopMs: number): void;
Defined in: spin/phases/AnticipationPhase.ts:306
Hold until the reel has covered _cells pitches since the final leg
began. update does the watching; backstopMs is the ceiling that keeps a
reel which stopped moving from hanging the spin forever.
Parameters#
| Parameter | Type |
|---|---|
backstopMs | number |
Returns#
void
_complete()#
protected _complete(): void;
Defined in: spin/phases/ReelPhase.ts:254
Call when the phase naturally completes.
Returns#
void
Inherited from#
_endTease()#
protected _endTease(): void;
Defined in: spin/phases/AnticipationPhase.ts:204
The tease reached its end: resolve the tease step, which completes the phase.
Returns#
void
_holdFor()#
protected _holdFor(ms: number, done: () => void): void;
Defined in: spin/phases/AnticipationPhase.ts:290
GSAP-driven wait, so a hidden tab pauses the tease with everything else.
Parameters#
| Parameter | Type |
|---|---|
ms | number |
done | () => void |
Returns#
void
_kill()#
protected _kill(): void;
Defined in: spin/phases/AnticipationPhase.ts:332
Returns#
void
_runSegment()#
protected _runSegment(): void;
Defined in: spin/phases/AnticipationPhase.ts:209
Play _segments[_segmentIndex], then chain to the next or finish.
Returns#
void
_startTease()#
protected _startTease(config: AnticipationPhaseConfig): void;
Defined in: spin/phases/AnticipationPhase.ts:155
Play the tease config describes; _endTease() when it is over.
Parameters#
| Parameter | Type |
|---|---|
config | AnticipationPhaseConfig |
Returns#
void
_warnIfDriveMissedBudget()#
protected _warnIfDriveMissedBudget(seg: AnticipationSegment, target: number): void;
Defined in: spin/phases/AnticipationPhase.ts:271
A drive that could not reach a segment’s speed inside the segment’s time budget plays a DIFFERENT tease from the one that was written, and the next leg’s retarget hides the evidence. Say so once rather than letting the tween and drive models silently disagree on identical config.
Parameters#
| Parameter | Type |
|---|---|
seg | AnticipationSegment |
target | number |
Returns#
void
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#
| Parameter | Type |
|---|---|
options | BounceOptions |
Returns#
Inherited from#
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#
| Parameter | Type |
|---|---|
ctx | BounceContext |
Returns#
Animation
Inherited from#
defaultSteps()#
defaultSteps(): PhaseStep<AnticipationStepContext>[];
Defined in: spin/phases/AnticipationPhase.ts:127
The built-in list: the whole tease is one cuttable step.
Returns#
PhaseStep<AnticipationStepContext>[]
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#
| Parameter | Type |
|---|---|
ctx | SkipContext<SpeedProfile> |
Returns#
void
Inherited from#
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#
| Parameter | Type | Description |
|---|---|---|
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#
onEnter()#
protected onEnter(config: AnticipationPhaseConfig): void;
Defined in: spin/phases/AnticipationPhase.ts:149
Subclass: set up the phase (start tweens, set speed, etc).
Parameters#
| Parameter | Type |
|---|---|
config | AnticipationPhaseConfig |
Returns#
void
Overrides#
onSkip()#
protected onSkip(_ctx?: SkipContext): void;
Defined in: spin/phases/AnticipationPhase.ts:324
A tease has no landing of its own to protect: ending it early and
returning the reel to full speed IS its natural end, so a 'quicken'
completes here too. The stop that follows crawls the frame in from there.
Parameters#
| Parameter | Type |
|---|---|
_ctx | SkipContext |
Returns#
void
Overrides#
run()#
run(config: AnticipationPhaseConfig): Promise<void>;
Defined in: spin/phases/ReelPhase.ts:173
Enter the phase. Returns a promise that resolves when the phase is complete.
Parameters#
| Parameter | Type |
|---|---|
config | AnticipationPhaseConfig |
Returns#
Promise<void>
Inherited from#
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#
| Parameter | Type |
|---|---|
steps | readonly PhaseStep<StepContext<any, any>>[] |
Returns#
void
Inherited from#
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#
| Parameter | Type |
|---|---|
ctx | SkipContext<SpeedProfile> |
Returns#
void
Inherited from#
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#
update()#
update(_deltaMs: number): void;
Defined in: spin/phases/AnticipationPhase.ts:310
Called each frame while the phase is active.
Parameters#
| Parameter | Type |
|---|---|
_deltaMs | number |
Returns#
void