cLib.DAnimatedLabel
Label with typewriter animation effect.
Basic Usage
local label = vgui.Create("cLib.DAnimatedLabel", parent)
label:SetFont("cLib.Text")
label:SetText("This text will appear character by character!")
label:Dock(TOP)Methods
| Method | Description |
|---|---|
SetText(string) | Set text (starts animation) |
SetFont(string) | Set font |
SetTextColor(Color) | Set text color |
SetAnimationSpeed(number) | Seconds per character |
Skip() | Skip to end |
Reset() | Restart animation |
IsAnimating() | Check if still animating |
Customization
local label = vgui.Create("cLib.DAnimatedLabel", parent)
label:SetFont("cLib.Title")
label:SetTextColor(cLib.GetColor("cLib.accent"))
label:SetAnimationSpeed(0.03) -- Faster (default: 0.05)
label:SetText("Welcome to the server!")Callbacks
label.OnAnimationComplete = function(self)
print("Animation finished!")
-- Maybe show next element
nextButton:SetVisible(true)
endSkip on Click
local label = vgui.Create("cLib.DAnimatedLabel", parent)
label:SetText("Click to skip this long introduction text...")
label.OnMousePressed = function(self)
if self:IsAnimating() then
self:Skip()
end
endSequential Labels
local texts = {
"Welcome to the tutorial.",
"This will teach you the basics.",
"Let's get started!"
}
local currentIndex = 1
local label = vgui.Create("cLib.DAnimatedLabel", parent)
local function ShowNext()
if currentIndex <= #texts then
label:SetText(texts[currentIndex])
currentIndex = currentIndex + 1
end
end
label.OnAnimationComplete = function(self)
timer.Simple(1, ShowNext) -- Wait 1 second between texts
end
ShowNext() -- Start first text