Thread Tools Display Modes
04-09-09, 02:04 PM   #1
Geebles
A Murloc Raider
Join Date: Apr 2009
Posts: 8
Question Alpha Fading Text or Frames

I'm trying to get a frame to alpha fade out. I've found these function, but they don't appear to work:
wowwiki.com/API_UIFrameFadeIn
wowwiki.com/API_UIFrameFlash

Has anyone been able to get them to work? Or know another way? I haven't been able to find any kind of timeout function for lua...
  Reply With Quote
04-09-09, 02:29 PM   #2
Geebles
A Murloc Raider
Join Date: Apr 2009
Posts: 8
Lightbulb

I'm trying this right now, though I'm not sure it is the best way...

The triggering event sets a variable:
Code:
AlphaVariable = 4;
And the frame I want to fade has:
Code:
<OnUpdate>
if(AlphaVariable>0) then
	AlphaVariable = AlphaVariable-0.1;
	this:SetAlpha(AlphaVariable);
end
</OnUpdate>
It will only begin to fade once goes below 1. Anything higher provides a delay, before fading. So initially setting it to 4 provides a slight delay.
  Reply With Quote
04-09-09, 04:51 PM   #3
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 772
Do you want the frame to fade out when you are Out of Combat? When? On choice?

You can use the following to get started:

frame:SetAlpha(value) - sets the alpha value of a frame
frame:RegisterEvent("event") - registers an event that you can later use to do things when it triggers
PLAYER_REGEN_DISABLED - an event that is triggered when you ENTER combat
PLAYER_REGEN_ENABLED - when you leave combat
PLAYER_ENTERING_WORLD - when you see a loading screen (this is only useful if you want to start out with an alpha value of something OTHER than 1)

You will need to use these events under your OnEvent function. Something like this:
Code:
function OnEvent(self, event, arg1)
    if (event == "PLAYER_REGEN_DISABLED") then
        frame:SetAlpha(in_combat_value_here)
    elseif (event == "PLAYER_REGEN_ENABLED") then
        frame:SetAlpha(out_combat_value_here)
    end
end
Hope I helped you out somehow!
__________________
Never be satisfied with satisfactory.
  Reply With Quote
04-10-09, 04:41 PM   #4
Aezay
A Theradrim Guardian
 
Aezay's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 66
Something like this might be what you are looking for. Just set the frame's fadeTime to a value in seconds, and the frame will fadeout over that time.
Code:
local frame.fadeElapsed = 0;

local function OnUpdate(self,elapsed)
	-- Normal update here
	if (not self.fadeTime) then
		-- code
	-- FadeOut
	elseif (self.fadeElapsed <= self.fadeTime) then
		self.fadeElapsed = (self.fadeElapsed + elapsed);
		self:SetAlpha(1 - self.fadeElapsed / self.fadeTime);
	else
		self:Hide();
	end
end
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Alpha Fading Text or Frames


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off