View Single Post
11-25-13, 10:07 AM   #4
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Originally Posted by Phanx View Post

Code:
-- create the parent frame once:
local frame = CreateFrame("Frame", "MyAddon", UIParent)
frame:SetPoint("BOTTOM", UIParent, "CENTER", 0, 100)
frame:SetSize(256, 256)
frame:Hide()

-- create the texture object once:
local tex = frame:CreateTexture(nil, "ARTWORK")
tex:SetAllPoints(true)
frame.texture = tex

-- when you want to show a specific texture:
frame.texture:SetTexture("Interface\\AddOns\\MyAddon\\textures\\blabla")
frame:Show()
If you had, say, 4 textures, and you only needed to show one at a time, something like this should work (taking from Phanx's lead).

** Edit: that is some wonky indentation, forum gods!
Code:
-- when you want to show a specific texture:
-- your textures are named "blabla1.tga", "blabla2.tga", etc
local counter
frame:SetScript("OnUpdate", function(self, elapsed)
	for i = 1, 4 do
		counter = counter + elapsed -- WoW increments in 0.1 seconds
		frame.texture:SetTexture("Interface\\AddOns\\MyAddon\\textures\\blabla"..i)
		frame:Show()
		if counter == 2 then
			-- hide this frame at two seconds
			frame:Hide()
		end
		counter = 0
	end
end)
  Reply With Quote