TweenFlip

View source

Marks an entity’s concrete tween for endpoint swapping.

Attach this empty component alongside a concrete tween such as Position2DTween. When the matching TweenPlugin is registered, the tween swaps its from and to endpoints after its elapsed time reaches its duration.

Flipping does not reset the elapsed time. Because the timer remains at the duration, an entity with only this marker can swap endpoints again on each later update. Add TweenRepeat when each flip should start a new timed cycle; the repeat marker resets the elapsed time to 0. The marker has no fields of its own, and its constructor takes no options.

Examples

import { World } from '@wimaengine/ecs'
import { Position2D } from '@wimaengine/transform'
import { Position2DTween, TweenFlip } from '@wimaengine/tween'

const world = new World()
world.spawn([
  new Position2D(0, 0),
  new Position2DTween(
    new Position2D(10, 0),
    new Position2D(0, 0),
    1
  ),
  new TweenFlip()
])
// Register the tween plugin on the app that runs this world.

Constructor


constructor()

Methods


staticcopy(source: TweenFlip, target?: TweenFlip): TweenFlip

View source

Returns an empty marker target without copying state.

TweenFlip has no fields, so source is not read. When target is omitted, a new marker is returned; otherwise the exact target is returned unchanged.

Parameters

NameDescriptionDefault
source

Marker source; it has no state to read.

—
target?

Marker to return unchanged.

...

Returns

The supplied target or a new empty marker.

staticclone(target: TweenFlip): TweenFlip

View source

Creates an empty marker because there is no state to clone.

This delegates to TweenFlip.copy without a target, so the result is always a new TweenFlip instance.

Parameters

NameDescriptionDefault
target

Marker source; it is not read.

—

Returns

A new empty marker.