API Cooldown SetCooldown

From Wowpedia
Jump to: navigation, search
Cooldown animation

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 display the "cooldown finished" flash:

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

See Also