Scale2DTween

View source

ExtendsTween

Tweens an entity’s Scale2D component in 2D space.

Scale2DTween is the concrete ECS component for tweening Scale2D values. Attach it to the same entity as the target component and register a matching TweenPlugin, or use DefaultTweenPlugin for the standard transform integrations. The inherited tween contract is documented by Tween.

Examples

import { World } from '@wimaengine/ecs'
import { Scale2D } from '@wimaengine/transform'
import { Scale2DTween } from '@wimaengine/tween'

// Register DefaultTweenPlugin on the app that runs this world.
const world = new World()
world.spawn([
  new Scale2D(1, 1),
  new Scale2DTween(
    new Scale2D(2, 2),
    new Scale2D(1, 1),
    0.5
  )
])

Constructor


constructor(to: Scale2D, from: Scale2D, duration: number, repeat?: boolean, flip?: boolean, easing?: EasingFn)

View source

Creates tween state for an ending value, starting value, and duration.

Values are assigned directly; the constructor does not clone to or from, or validate duration. The optional booleans are stored on the instance; use TweenRepeat and TweenFlip to opt into repeated cycles and endpoint swapping.

Parameters

NameDescriptionDefault
to

Value passed to interpolation at progress 1.

—
from

Value passed to interpolation at progress 0.

—
duration

Total tween duration in seconds.

—
repeat?

Stored repeat option.

false
flip?

Stored flip option.

true
easing?

Function applied to normalized progress.

Easing.linear