Tween
Inherits Observable
Writeable observable which holds a value which can be re-assigned via State:Set
Constructor
Dex.Tween
Dex.Tween<T>(
initialValueOrPlayInput: T | Observable<TweenParams<T>>
) -> Tween<T>
Creates a new Tween observable which simulates transitions between values over time.
If an initial value is passed in, the tween will start at the initial value provided must be played by calling the Tween:Play method
If an input observable is passed in, the tween will automatic play based on whenever that observable changes, using [TweenParams] specified by the input observable's current value.
Tweens can either be played by calling the :Play()
method
local tween = Dex.Tween(0)
tween:Play({
goal = 1,
info = TweenInfo.new(0.1)
})
…or automatically play when an input state holding a params table changes:
local input = Dex.State(0)
local tween = Dex.Tween(Dex.Map(input)(function(currentInput)
return {
goal = input,
info = TweenInfo.new(0.1)
}
end))
input:Set(1)
Both methods of tween dispatching can be useful in different scenarios.
INFO
Tweens must currently be Subscribed or Mounted to exhibit expected behavior. This is a requirement for all realtime-simulated observables, which enables safe garbage collection when writing Dex components.
Functions
Play
Tween:
Play
(
params:
TweenParams
<
T
>
) →
(
)
Types
interface
TweenParams<T> {
}
Plays