Thread Tools Display Modes
09-14-14, 02:56 PM   #1
sticklord
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 57
AnimationGroups and lua/xml

I was playing around with some animations, and tried to get one AnimationGroup to control many objects. I found some methods on wowprogramming that seemed like they could do it but they didn't exist (AlphaAnim:SetTarget(), AlphaAnim:SetTargetKey()). Then i checked out the PriestBar by Blizzard and got it working, but had to use xml ( ). Here's how i did it through xml:

Lua Code:
  1. <Frame name="ArcaneOrbs" virtual="true">
  2.     <Animations>
  3.         <AnimationGroup parentKey="animIn">
  4.             <Alpha target="$parentHighlight" change="1" duration="0.2" order="1"/>
  5.             <Alpha target="$parentOrb" change="1" duration="0.2" order="1"/>
  6.             <Alpha target="$parentGlow" change="1" duration="0.2" order="1"/>
  7.             <Alpha target="$parentGlow" change="-1" duration="0.25" order="2"/>
  8.             <Scripts>
  9.                 <OnPlay>
  10.                     self:GetParent().orb:SetAlpha(0.5);
  11.                     self:GetParent().orb:Show();
  12.                     self:GetParent().highlight:SetAlpha(0.5);
  13.                 </OnPlay>
  14.                 <OnFinished>
  15.                     self:GetParent().orb:SetAlpha(1.0);
  16.                     self:GetParent().highlight:SetAlpha(1.0);
  17.                 </OnFinished>
  18.             </Scripts>
  19.         </AnimationGroup>
  20.     </Animations>
  21.         <Layers>
  22.         <Layer level="ARTWORK">
  23.             <Texture name="$parentOrb" parentKey="orb" ...>
  24.             <Texture name="$parentHighlight" parentKey="highlight" ...>
  25.         </Layer>
  26.         <Layer level="OVERLAY">
  27.             <Texture name="$parentGlow" parentKey="glow" .. >
  28.             </Texture>
  29.         </Layer>
  30.     </Layers>
  31. </Frame>

I guess they use the target = "$parentOrb" to choose which texture they control with the animation, but is there a way to do this using Lua only?
  Reply With Quote
09-14-14, 09:03 PM   #2
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
I would say you're looking for Animation:SetTarget().
  Reply With Quote
09-14-14, 11:10 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Behold, the useful glory of widget API documentation.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
09-15-14, 12:54 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
This thread may be helpful aswell: http://www.wowinterface.com/forums/s...ad.php?t=35104
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
09-15-14, 12:59 AM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by zork View Post
But replace all instances of "wowwiki.com" in those links with "wowpedia.org" as that thread is from 2010 and most of the regular editors moved to Wowpedia after WoWWiki got assimilated into the Wikia collective and filled with annoying ads and painfully slow javascripts that do nothing useful.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
09-15-14, 10:54 AM   #6
sticklord
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 57
Thanks for the responses guys!

But as i ment, Anim:SetTargetKey() & Anim:SetTarget() both give an error: attempt to call method "SetTarget" (a nil value).

This is what I used:
Lua Code:
  1. local function AddAlphaAnimation(parent, change, dur, order, target)
  2.     local a = parent:CreateAnimation("ALPHA")
  3.     a:SetDuration(dur)
  4.     a:SetOrder(order)
  5.     a:SetChange(change)
  6. --  a:SetTargetKey("$parent"..target) doesn't exist
  7. --  a:SetTarget("$parent"..target)    neither do this 1
  8.     return a
  9. end
  10.  
  11. for i = 1, 4 do
  12.     local name = "MageArcaneOrb"..i
  13.     local orb = CreateFrame("Frame", name, f)
  14.     orb:SetPoint("LEFT", (i*35)-55, 0)
  15.     orb:SetSize(48, 48)
  16.     orb:SetAlpha(0)
  17.  
  18.     orb.fill = orb:CreateTexture(name.."Fill", "ARTWORK")
  19.     orb.fill:SetTexture("Interface\\AddOns\\oUF_Abu\\Media\\Frames\\Mage\\Fill")
  20.     orb.fill:SetAllPoints(orb)
  21.     orb.fill:SetSize(48, 48)
  22.     orb.glow = orb:CreateTexture(name.."Glow", "OVERLAY")
  23.     orb.glow:SetAllPoints(orb)
  24.     orb.glow:SetSize(48, 48)
  25.     orb.glow:SetBlendMode("ADD")
  26.     orb.glow:SetTexture("Interface\\AddOns\\oUF_Abu\\Media\\Frames\\Mage\\Flash")
  27.  
  28.     orb.AnimIn = orb:CreateAnimationGroup("AnimIn")
  29.     AddAlphaAnimation(orb.AnimIn, 1, 0.2, 1, "Fill")
  30. --  AddAlphaAnimation(orb.AnimIn, 1, 0.2, 1, "Glow")
  31. --  AddAlphaAnimation(orb.AnimIn, -1, 0.25, 2, "Glow")
  32.  
  33.     orb.AnimIn:SetScript("OnPlay", function(self)
  34.         self:GetParent():SetAlpha(0.5);
  35.     end)
  36.     orb.AnimIn:SetScript("OnFinished", function(self)
  37.         self:GetParent():SetAlpha(1.0);
  38.     end)
  39.  
  40.     orb.AnimOut = orb:CreateAnimationGroup("AnimOut")
  41.     AddAlphaAnimation(orb.AnimOut, -1, 0.2, 1, "Fill")
  42. --  AddAlphaAnimation(orb.AnimOut, 1, 0.2, 1, "Glow")
  43. --  AddAlphaAnimation(orb.AnimOut, -1, 0.25, 2, "Glow")
  44.  
  45.     orb.AnimOut:SetScript("OnFinished", function(self)
  46.         self:GetParent():SetAlpha(0.0);
  47.     end)
  48.     f[i] = orb;
  49. end

I guess i could make a group for each texture but then it would probably be better to skip the animationgroup stuff and just make my own OnUpdate script. I'm gonna stick to xml

Last edited by sticklord : 09-15-14 at 11:01 AM.
  Reply With Quote
09-15-14, 11:46 AM   #7
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
I just did some quick testing in game and I can confirm that Animations definitely don't have a SetTarget or SetTargetKey method.

I can't see any way to have a single animation group contain animations acting on multiple unique regions without using XML.
  Reply With Quote
09-15-14, 01:25 PM   #8
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Ups.

Animation:SetChildKey() is inexistent too.

Btw: what's the difference between
Code:
<Alpha target="" .../>
and
Code:
<Alpha targetKey="" .../>
at all?

Last edited by Duugu : 09-15-14 at 01:28 PM.
  Reply With Quote
09-15-14, 01:44 PM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
The same as the difference between "parent" and "parentKey" I'd suspect...
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
09-15-14, 01:52 PM   #10
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
An what is ...

... ah whatever. Doesn't matter at all.
  Reply With Quote
09-15-14, 02:45 PM   #11
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
XML:
<Frame name="MyBadlyNamedFrame" parent="UIParent">
Lua:
CreateFrame("Frame", "MyBadlyNamedFrame", UIParent)

XML:
<Frame parent="UIParent" parent="UIParent" parentKey="badFrame">
Lua:
UIParent.badFrame = CreateFrame("Frame", nil, UIParent)

Therefore I'd assume that target="x" expects "x" to be global name of the object to act on, while targetKey="x" expects "x" to be a key whose value is a reference to the object to act on. Whether the key is expected to be on the animation, the animation group, or their parent frame, however, I don't know. You could probably figure it out easily by looking at the default UI code, but I don't actually care, so I'm not going to spend time going and looking it up.

-----

Also, it looks like WoWProgramming lists several methods that don't actually exist for both Animation and AnimationGroup widgets, and is missing an AnimationGroup method.

Animation
  • SetChildKey does not actually exist
  • SetTarget does not actually exist
  • SetTargetKey does not actually exist

AnimationGroup (generic untyped)
  • GetInitialOffset is missing from the list
  • IsSetToFinalAlpha does not actually exist
  • SetToFinalAlpha does not exist

However, I'm pretty sure I saw a post about IsSetToFinalAlpha and SetToFinalAlpha being new methods for WOD, so it's likely the other methods listed above as nonexistent are also new methods coming in WOD. No idea about GetInitialOffset; possibly removed in WOD?
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 09-15-14 at 02:52 PM.
  Reply With Quote
09-15-14, 03:30 PM   #12
sticklord
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 57
Hey don't hurt my feelings!

Yeah, I compared the new WoD template where they for example used childKey="Bg" instead of target="$parentGlow", where childKey is the same as targetKey suppose. And they also use the new fromAlpha="0" and toAlpha="1" so you don't have to hook the script to get the correct alpha I suppose.

Probably best to stay away from this until WoD is released
  Reply With Quote
09-16-14, 01:40 AM   #13
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Actually not. Failures move you forward. The more you fail the better.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
09-16-14, 09:24 AM   #14
sticklord
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 57
What i ment was that i would just use xml until the expansion is released, when it's probably impossible to do control multiple regions with a single group using lua.

On the other hand, I tested the new functions on the PTR and got it working!

Lua Code:
  1. local function CreateAlphaAnim(par, key, from, to, dur, order)
  2.     local a = par:CreateAnimation("ALPHA")
  3.     a:SetFromAlpha(from)
  4.     a:SetToAlpha(to)
  5.     a:SetDuration(dur)
  6.     --a:SetChildKey(key) -- "fill"
  7.     a:SetTarget(key) --name.."Fill"
  8.     --a:SetTargetKey(key)
  9.     a:SetOrder(order)
  10.     print(a:GetRegionParent():GetName())
  11.     return a
  12. end
  13.  
  14. for i = 1, 4 do
  15.     local name = "orb"..i
  16.     local orb = CreateFrame("Frame", name, f)
  17.     orb:SetPoint("LEFT", (i*35)-55, 0)
  18.     orb:SetSize(48,48)
  19.     orb:Show()
  20.  
  21.     orb.fill = orb:CreateTexture(name.."Fill", "ARTWORK")
  22.     orb.fill:SetAlpha(0)
  23.     orb.fill:SetTexture("Interface\\AddOns\\oUF_Abu\\Media\\Frames\\Mage\\Fill")
  24.     orb.fill:SetVertexColor(1, .8, .8)
  25.     orb.fill:SetAllPoints(orb)
  26.  
  27.     orb.glow = orb:CreateTexture(name.."Glow", "OVERLAY")
  28.     orb.glow:SetAlpha(0)
  29.     orb.glow:SetBlendMode("ADD")
  30.     orb.glow:SetTexture("Interface\\AddOns\\oUF_Abu\\Media\\Frames\\Mage\\Flash")
  31.     orb.glow:SetAllPoints(orb)
  32.  
  33.     orb.AnimIn = orb:CreateAnimationGroup("AnimIn")
  34.     orb.AnimIn:SetToFinalAlpha(true)
  35.     CreateAlphaAnim(orb.AnimIn, name.."Fill", 0, 1, 0.2, 1)
  36.     CreateAlphaAnim(orb.AnimIn, name.."Glow", 0,   1, 0.2, 1)
  37.     CreateAlphaAnim(orb.AnimIn, name.."Glow", 1,   0, 0.2, 2)
  38.  
  39.     orb.AnimOut = orb:CreateAnimationGroup("AnimOut")
  40.     orb.AnimOut:SetToFinalAlpha(true)
  41.     CreateAlphaAnim(orb.AnimOut, name.."Glow", 0, 1,   0.2, 1)
  42.     CreateAlphaAnim(orb.AnimOut, name.."Glow", 1, 0,   0.2, 2)
  43.     CreateAlphaAnim(orb.AnimOut, name.."Fill", 1, 0, 0.2, 2)
  44.    
  45.     f[i] = orb;
  46. end

I found out that A:SetChildKey() requires the key of the frame, so if we want to control orb.fill we just use "fill". A:SetTarget() require the name of the frame, so "orb1Fill". Couldn't get A:SetTargetKey() working but it do exist in WoD.

A:GetRegionParent() still returned the parentframe of the AnimationGroup though, but I'm not sure how this is supposed to work.

Last edited by sticklord : 09-16-14 at 09:29 AM.
  Reply With Quote
09-16-14, 09:48 AM   #15
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
"key" refers to the name of the key in the table. "glow" is the key in "orb.glow"
  Reply With Quote
09-16-14, 10:20 AM   #16
sticklord
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 57
Originally Posted by semlar View Post
"key" refers to the name of the key in the table. "glow" is the key in "orb.glow"
Yeah, thats what SetChildKey() uses.

I tried "$parentFill", "Fill" and some more with SetTargetKey() but nope, not a chance. But we still have two ways to set the frame, I'm alright without a third:P
  Reply With Quote
09-16-14, 10:41 AM   #17
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Your key is called "fill" (orb.fill) and is case-sensitive, have you tried that?
  Reply With Quote
09-16-14, 11:23 AM   #18
sticklord
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 57
Originally Posted by semlar View Post
Your key is called "fill" (orb.fill) and is case-sensitive, have you tried that?
Yeah, tried that aswell. Won't work sadly. But as I said Anim:SetChildKey("fill") works. I can put whatever I want in its arguments and it won't report bad usage:/ I'm just trying to figure out what SetTargetKey() is good for.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » AnimationGroups and lua/xml


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