Constructor
new Tween(callback, startopt, endopt, durationopt, optionsopt)
Create a new tween. The callback fires immediately with start so the target snaps to the start value on the same frame the tween is created.
start and end may be numbers, Vector2 instances, Color instances, or any object exposing a lerp(other, percent) => sameType method. The callback receives the interpolated value (a number, or a fresh instance for lerp-able types). Both endpoints must be the same type.
| Name | Type | Attributes | Default | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
callback | ||||||||||||||||||||||||
start | number | | <optional> | 0 | Starting value | ||||||||||||||||||||
end | number | | <optional> | 1 | Ending value | ||||||||||||||||||||
duration | number | <optional> | 1 | Duration in seconds | ||||||||||||||||||||
options | Object | <optional> | Properties
|
- Source
// Animate a fade-out over 2 seconds with an ease-out sine curve.
new Tween((v) => obj.alpha = v, 1, 0, 2, { ease: Ease.OUT(Ease.SINE) });