import { EasingFunction } from "./easing.js";
import { InterpolationFunction } from "./interpolation.js";
/**
* A tweening engine for smoothly interpolating object properties over time.
* Based on tween.js with
* optimised Robert Penner's equations.
*
* Tweens use an event-based lifecycle — on `start()` the tween subscribes to
* the game loop events (`TICK`, `GAME_AFTER_UPDATE`, `STATE_PAUSE`,
* `STATE_RESUME`, `GAME_RESET`)
* and automatically unsubscribes on completion or `stop()`.
* They do not need to be added to a container.
* @example
* // basic usage
* new me.Tween(myObject.pos)
* .to({ x: 200, y: 200 }, { duration: 3000, easing: me.Tween.Easing.Bounce.Out })
* .onComplete(() => console.log("done!"))
* .start();
* @example
* // auto-start with options
* new me.Tween(myObject.pos).to({ x: 200 }, {
* duration: 1000,
* easing: me.Tween.Easing.Quadratic.InOut,
* yoyo: true,
* repeat: Infinity,
* autoStart: true,
* });
* @category Tweens
*/
export default class Tween {
/**
* whether the tween should persist across state changes (not auto-stopped on game reset)
* @default false
*/
isPersistent: boolean;
/**
* whether the tween should keep running when the game is paused
* @default false
*/
updateWhenPaused: boolean;
/**
* @param object - the object whose properties will be tweened
*/
constructor(object: object);
/**
* Define the target property values and tween options.
* @param properties - target property values to tween to (e.g. `{ x: 200, y: 100 }`)
* @param [options] - tween configuration
* @param [options.duration] - tween duration in milliseconds
* @param [options.easing] - easing function (e.g. `Tween.Easing.Quadratic.InOut`)
* @param [options.delay] - delay before starting, in milliseconds
* @param [options.yoyo] - bounce back to original values when finished (use with `repeat`)
* @param [options.repeat] - number of times to repeat (use `Infinity` for endless loops)
* @param [options.repeatDelay] - delay in milliseconds before each repeat cycle
* @param [options.interpolation] - interpolation function for array values
* @param [options.autoStart] - start the tween immediately without calling `start()`
* @returns this instance for object chaining
*/
to(properties: Record, options?: {
duration?: number | undefined;
easing?: EasingFunction | undefined;
yoyo?: boolean | undefined;
repeat?: number | undefined;
delay?: number | undefined;
repeatDelay?: number | undefined;
interpolation?: InterpolationFunction | undefined;
autoStart?: boolean | undefined;
}): this;
/**
* Start the tween. Subscribes to game loop events and begins interpolation.
* @param [time] - the start time (defaults to current game time)
* @returns this instance for object chaining
*/
start(time?: number): this;
/**
* Stop the tween. Unsubscribes from all game loop events.
* @returns this instance for object chaining
*/
stop(): this;
/**
* delay the tween
* @param amount - delay amount expressed in milliseconds
* @returns this instance for object chaining
*/
delay(amount: number): this;
/**
* Repeat the tween
* @param times - amount of times the tween should be repeated
* @returns this instance for object chaining
*/
repeat(times: number): this;
/**
* Set a delay before each repeat.
* @param amount - delay in milliseconds before each repeat cycle
* @returns this instance for object chaining
*/
repeatDelay(amount: number): this;
/**
* Allows the tween to bounce back to their original value when finished.
* To be used together with repeat to create endless loops.
* @param yoyo flag
* @returns this instance for object chaining
*/
yoyo(yoyo: boolean): this;
/**
* set the easing function
* @param easing - easing function
* @returns this instance for object chaining
*/
easing(easing: EasingFunction): this;
/**
* set the interpolation function
* @param interpolation - interpolation function
* @returns this instance for object chaining
*/
interpolation(interpolation: InterpolationFunction): this;
/**
* chain the tween
* @param tweens - Tween(s) to be chained
* @returns this instance for object chaining
*/
chain(...tweens: Tween[]): this;
/**
* onStart callback
* @param onStartCallback - callback
* @returns this instance for object chaining
*/
onStart(onStartCallback: OnStartCallback