Thread Tools Display Modes
06-27-16, 08:33 PM   #1
n0t4h4cker
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Mar 2016
Posts: 5
Alpha Animation Script Issue

In my code, I have created a animation for a frame to fade in. (Alpha: 0 ----> Alpha: 1)
However when I set a script to set the alpha to 1 when the animation finishes (keep the frame shown),the SetAlpha on the frame does not stay.

Does anyone know what is going wrong?


Code:
local menuFrame = CreateFrame("Frame", "SAO_MainMenu", UIParent)
menuFrame:SetSize(120,300)
menuFrame:SetPoint("CENTER", UIParent, "CENTER")
menuFrame:SetAlpha(0)

-- Lock1
menuFrame.playerLock = CreateFrame("Button", "$parentLock1", menuFrame)
menuFrame.playerLock:SetSize(42,42)
menuFrame.playerLock:SetPoint("CENTER", "$parent", "TOP")
menuFrame.playerLock.text = menuFrame.playerLock:CreateTexture("bg_test", "ARTWORK")
menuFrame.playerLock.text:SetTexture("Interface\\AddOns\\sao\\media\\inventoryequipmentlock")
menuFrame.playerLock.text:SetSize(42,42)
menuFrame.playerLock.text:SetPoint("CENTER", "$parent", "CENTER")

-- Lock2
menuFrame.friendsLock = CreateFrame("Button", "$parentLock2", menuFrame)
menuFrame.friendsLock:SetSize(42,42)
menuFrame.friendsLock:SetPoint("TOP", "$parentLock1", "BOTTOM", 0, -5)
menuFrame.friendsLock.text = menuFrame.friendsLock:CreateTexture("bg_test2", "ARTWORK")
menuFrame.friendsLock.text:SetTexture("Interface\\AddOns\\sao\\media\\friendguildlock")
menuFrame.friendsLock.text:SetSize(42,42)
menuFrame.friendsLock.text:SetPoint("CENTER", "$parent", "CENTER")

-----------------------------------------------------
menuFrame.animation = menuFrame:CreateAnimationGroup()

local a1 = menuFrame.animation:CreateAnimation("Alpha")
a1:SetChange(1)
a1:SetDuration(1)
a1:SetScript("OnFinished", function(self) 
        print("Inside")
        menuFrame:SetAlpha(1)
end)
  Reply With Quote
06-28-16, 08:16 AM   #2
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
you need to add a1:Pause() in the onfinish function
  Reply With Quote
06-28-16, 01:50 PM   #3
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
SetChange has been removed in legion so it's probably best not to use it.

You can replace it with a1:SetFromAlpha(0) and a1:SetToAlpha(1), and add menuFrame.animation:SetToFinalAlpha(true) to keep its new value.
  Reply With Quote
06-28-16, 10:49 PM   #4
n0t4h4cker
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Mar 2016
Posts: 5
SetChange has been removed in legion so it's probably best not to use it.

You can replace it with a1:SetFromAlpha(0) and a1:SetToAlpha(1), and add menuFrame.animation:SetToFinalAlpha(true) to keep its new value
I will note this for legion, but I'm trying to get this work on live (wod 6.2).


you need to add a1:Pause() in the onfinish function
This doesn't really work with what I'm trying to do. I still won't be able to change alpha of the actual frame while in the animation.


Still haven't found a solution.
  Reply With Quote
06-29-16, 12:26 AM   #5
Gethe
RealUI Developer
 
Gethe's Avatar
Premium Member
Featured
Join Date: Sep 2008
Posts: 942
SetTo/FromAlpha are available on Live already, no reason to not use them.
__________________
Knowledge = Power; Be OP

  Reply With Quote
06-29-16, 02:31 PM   #6
n0t4h4cker
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Mar 2016
Posts: 5
I tried using the SetTo/SetFrom and didn't work, maybe I will re try and see if I did something wrong.

However I did manage to fix the issue by using
Code:
UIFrameFadeIn(frame, timeToFade, startAlpha, endAlpha)
function for the frame.
  Reply With Quote
06-29-16, 02:34 PM   #7
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Did you try the second part of what I wrote, which is what actually tells the animation group to keep the final alpha that it's set to?
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Alpha Animation Script Issue

Thread Tools
Display Modes

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