Tween
A library for writing efficient, simple interpolation code.
Setup:
;; ;
Here is the generalized form:
/** * Creates a Tween along a curve, with a callback to call each tick. * Connects an interpolation function to RunService.RenderStepped if initialValue is a CFrame, * else RunService.Heartbeat. * @param totalDuration The total duration of the Tween * @param easingFunction The easingFunction to call each tick * @param callback The function to call each tick * @param initialValue The starting value to interpolate to push into the callback function each tick. default=0 * @param endValue The target value the initialValue should reach. default=1 * @param extraValue1 An extra value to be passed into the easingFunction * @param extraValue2 An extra value to be passed into the easingFunction */declare ;
Here is the simplest form:
This will return a Tween object, and connect this interpolation to RunService.Heartbeat. x will be a number along the Standard curve [0, 1]. The interpolation will last 1 second. Standard is the EasingFunction, which is the curve along which this interpolation will animate.
Tween1, Standard, printx;
Functions that interpolate CFrames will instead connect to RunService.RenderStepped.
;;; // binds to RenderSteppedTween2, Deceleration, Camera.CFrame = Position, StartPosition, EndPosition;
StartPosition and EndPosition can be basically any Roblox type (default = number), and this will be the type that gets passed into the callback.
;;;myObj.Parent = Workspace // The last two 0.5 arguments will be passed into OutElastic, as parameters representing amplitude and periodTween1, OutElastic, printx, myObj.Color, blue, 05, 05
When lerping Color3 values, it will automatically lerp across the CIELUV Color space:
PseudoTween Object
Calling the Tween function will return a PseudoTween, which has pretty much the same API as Roblox's TweenBase.
/** * A Tween Object */