Here's a small demo:
Lua Code:
local frame = CreateFrame("Frame")
local textsToAnimate = {}
local function OnUpdate(self, elapsed)
for _, text in pairs(textsToAnimate) do
text:UpdateAnimatedValue(elapsed)
end
end
frame:SetScript("OnUpdate", OnUpdate)
frame:SetScript("OnEvent", function()
local text = UIParent:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
text:SetPoint("CENTER", -128, 64)
Mixin(text, AnimatedNumericFontStringMixin)
table.insert(textsToAnimate, text)
text = UIParent:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
text:SetPoint("CENTER", -128, 32)
Mixin(text, AnimatedNumericFontStringMixin)
table.insert(textsToAnimate, text)
text = UIParent:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
text:SetPoint("CENTER", -128, 0)
Mixin(text, AnimatedNumericFontStringMixin)
table.insert(textsToAnimate, text)
text = UIParent:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
text:SetPoint("CENTER", -128, -32)
Mixin(text, AnimatedNumericFontStringMixin)
table.insert(textsToAnimate, text)
C_Timer.NewTicker(2, function()
for _, text in pairs(textsToAnimate) do
text:SetAnimatedValue(math.random(10, 10000))
end
end)
end)
frame:RegisterEvent("PLAYER_LOGIN")