From Warcraft Wiki
Jump to navigation Jump to search

Shows a cooldown animation.

Cooldown:SetCooldown(start, duration [, modRate])


number - The time when the cooldown started (as returned by GetTime()). Zero if no cooldown.
number - Cooldown duration in seconds. Zero if no cooldown.
number? = 1 - The rate at which the animation should be updated.


Cooldown animation
  • 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.


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)
local myTexture = myFrame:CreateTexture()
local myCooldown = CreateFrame("Cooldown", "myCooldown", myFrame, "CooldownFrameTemplate")

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

  • Legion Patch 7.1.0 (2016-10-25): The modRate argument was added.
  • Warlords of Draenor Patch 6.0.2 (2014-10-14): The charges and maxCharges arguments were removed.
  • Mists of Pandaria Patch 5.1.0 (2012-11-27): This function now also manages the visibility of the widget it is called on.
  • Mists of Pandaria Patch 5.0.4 (2012-08-28): The third argument, drawEdgeOnly was replaced by charges and maxCharges arguments.

See Also