Fading Text Frame
This code will create a frame that can show text in the middle of the players screen. It will hold this text for 3 seconds and then fade it out. This is very similar to the code that blizzard uses for zone changing.
Snippet
MOD_TextFrame = CreateFrame("Frame");
MOD_TextFrame:ClearAllPoints();
MOD_TextFrame:SetHeight(300);
MOD_TextFrame:SetWidth(300);
MOD_TextFrame:SetScript("OnUpdate", MOD_TextFrame_OnUpdate);
MOD_TextFrame:Hide();
MOD_TextFrame.text = MOD_TextFrame:CreateFontString(nil, "BACKGROUND", "PVPInfoTextFont");
MOD_TextFrame.text:SetAllPoints();
MOD_TextFrame:SetPoint("CENTER", 0, 200);
MOD_TextFrameTime = 0;
function MOD_TextFrame_OnUpdate()
if (MOD_TextFrameTime < GetTime() - 3) then
local alpha = MOD_TextFrame:GetAlpha();
if (alpha ~= 0) then MOD_TextFrame:SetAlpha(alpha - .05); end
if (alpha == 0) then MOD_TextFrame:Hide(); end
end
end
function MOD_TextMessage(message)
MOD_TextFrame.text:SetText(message);
MOD_TextFrame:SetAlpha(1);
MOD_TextFrame:Show();
MOD_TextFrameTime = GetTime();
end
Posted by l3gsh0t at Tue, 08 Feb 2011 23:34:31 +0000