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) });Members
callback
Properties| Type | Description |
|---|---|
- Source
duration
Properties| Type | Description |
|---|---|
| number | Total duration in seconds |
- Source
ease
Properties| Type | Description |
|---|---|
| function | Easing curve mapping [0,1] -> [0,1] |
- Source
end
Properties| Type | Description |
|---|---|
| number | | Ending value |
- Source
life
Properties| Type | Description |
|---|---|
| number | Remaining time in seconds (counts down from duration to 0) |
- Source
paused
Properties| Type | Description |
|---|---|
| boolean | If true, stop advancing until cleared |
- Source
start
Properties| Type | Description |
|---|---|
| number | | Starting value |
- Source
useRealTime
Properties| Type | Description |
|---|---|
| boolean | If true, advance even when the game is paused |
- Source