WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Alpha Animation Script Issue (https://www.wowinterface.com/forums/showthread.php?t=53786)

n0t4h4cker 06-27-16 08:33 PM

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)


ObbleYeah 06-28-16 08:16 AM

you need to add a1:Pause() in the onfinish function

semlar 06-28-16 01:50 PM

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.

n0t4h4cker 06-28-16 10:49 PM

Quote:

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).


Quote:

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.

Gethe 06-29-16 12:26 AM

SetTo/FromAlpha are available on Live already, no reason to not use them.

n0t4h4cker 06-29-16 02:31 PM

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.

semlar 06-29-16 02:34 PM

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?


All times are GMT -6. The time now is 02:01 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI