The API is no longer being updated here until further notice. |
Shows a cooldown animation on a cooldown frame.
obj:SetCooldown(start, duration[, modRate])
Arguments[]
- start
- Number - The time when the cooldown started (as returned by GetTime()). Zero if no cooldown.
- duration
- Number - Cooldown duration in seconds. Zero if no cooldown.
- modRate
- Number - The rate at which the animation should be updated.
Details[]
- Calling this method will automatically show/hide the Cooldown widget. The widget, unless the animation is reversed, will also hide itself automatically when the animation completes.
Examples[]
First we create a container frame, a texture and a cooldown frame to work with:
local myFrame = CreateFrame("Frame", nil, UIParent)
myFrame:SetSize(80, 80)
myFrame:SetPoint("CENTER")
local myTexture = myFrame:CreateTexture()
myTexture:SetAllPoints()
myTexture:SetTexture("Interface\\Icons\\Ability_Druid_TreeofLife")
local myCooldown = CreateFrame("Cooldown", "myCooldown", myFrame, "CooldownFrameTemplate")
myCooldown:SetAllPoints()
Then we display a 10s cooldown animation on the cooldown frame:
myCooldown:SetCooldown(GetTime(), 10)
To display a 20s cooldown animation which started 5s ago:
myCooldown:SetCooldown(GetTime() - 5, 20)
To reset the cooldown animation and trigger the "cooldown finished" bling:
myCooldown:SetCooldown(0, 0)
To set the animation according to a cooldown of a spell in the spellbook we use:
local start, duration = GetSpellCooldown("Spell Name")
myCooldown:SetCooldown(start, duration)
Patch changes[]
- Patch 7.1.0 (2016-10-25): The
modRate
argument was added. - Patch 6.0.2 (2014-10-14): The
charges
andmaxCharges
arguments were removed. - Patch 5.1.0 (2012-11-27): This function now also manages the visibility of the widget it is called on.
- Patch 5.0.4 (2012-08-28): The third argument,
drawEdgeOnly
was replaced bycharges
andmaxCharges
arguments.