Introduction
Ever wanted to create amazing animated numbers with ease? Well then, I gotcha! Introducing my first ever open-sourced module NumberAnimation!
As seen in the above gif, The top label looks more appealing as it increments and the bottom one looks boring and lame with a sudden change. This is where NumberAnimation comes in handy. What’s appealing about the NumberAnimation class is the easiness to be used, Spring + Tween support, and some amazing little features that enhance this module.
API
function NumberAnimation.new(label, valueBase, styling)
returns a table
Params:
- label
Any Gui Instance with the Text property
- valueBase
A NumberValue or an IntValue which holds the relevant data
- styling
A dictionary with styling information
{
string Style = "Tween" or "Spring"
Depending on which style you want it to be animated
Tween = {
number Time = Any positive number - How long the tween should take to complete
string EasingStyle = Any TweenStyle - The style that the tween follows
string EasingDirection = "In" or "Out" or "InOut" - The direction for the TweenStyle to adhere to
}
Spring = {
number DampingRatio = Any number - Describes the shape of the spring
number Frequency = Any Number - Describes the speed of the spring
}
boolean Abbreviate = true or false
True if you want the number to be abbreviated false if you don't want
example;
Unabbreviated = 1000000
Abbreviated = 1M
}
NumberAnimation:SetPrefix(prefix: string)
return void/nil
Params:
- prefix = Any string
example;
Before = 1000
NumberAnimation:SetPrefix("$")
After = $1000
Example
local NumberAnimation = require(script.NumberAnimation)
local player = game:GetService("Players").LocalPlayer
local textLabel = player.PlayerGui:WaitForChild("ScreenGui").TextLabel
local coins = player.Coins
local coinsNumberAnimation = NumberAnimation.new(textLabel, coins, {
Style = "Tween",
Time = 1,
EasingStyle = "Quad",
EasingDirection = "InOut",
Abbreviate = true
})
coinsNumberAnimation:SetPrefix("$")
coinsNumberAnimation:Start()
Module
Credits
@boatbomber for BoatTween module
@Quenty for Maid class
@Fractality for spr module
NumberAnimation is completely free and open-source, It is my first open-sourced project! If you got any bugs or questions don’t hesitate to contact me at AmazingRocker#1015 or @AmazingRock3r