Thread Tools Display Modes
03-18-11, 05:36 PM   #1
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Whats wrong with the =(/§%ing AnimationGroup widget?

Hi everyone!

I'm trying to animate a fontstring object via an animation group:

local tframe = CreateFrame("Frame", "testframe", UIParent)
tframe:SetWidth(200)
tframe:SetHeight(200)
tframe:SetPoint("CENTER", UIParent, "CENTER")
tframe:Show()

local Texture = tframe:CreateTexture(nil,"OVERLAY")
Texture:ClearAllPoints()
Texture:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background")
Texture:SetPoint("BOTTOM", tframe,"BOTTOM")
Texture:Show()

local tFS = tframe:CreateFontString("PeonManagerWorldMapFontLayerLevelName", "OVERLAY")
tFS:SetFont("Fonts\\FRIZQT__.TTF", 30, "OUTLINE, MONOCHROME")
tFS:SetText("TestString")
tFS:SetTextColor(1, 1, 1, 1)
tFS:SetJustifyH("CENTER")
tFS:SetJustifyV("MIDDLE")
tFS:SetPoint("BOTTOM", tframe, "BOTTOM")

local ag = tframe:CreateAnimationGroup()

local a2 = ag:CreateAnimation("Scale")
a2:SetScale(1.5, 1.5)
a2:SetDuration(1)
a2:SetSmoothing("NONE")

local a2 = ag:CreateAnimation("Scale")
a2:SetStartDelay(1)
a2:SetScale(0.66, 0.66)
a2:SetDuration(1)
a2:SetSmoothing("NONE")

ag:SetLooping("REPEAT")
ag:Play()
This sample should create a frame, a texture, and a fontstring. The animation group then should play an endless 'pulse' animation.

It's working for the texture, but not for the fontstring. The fontstrings animation is only played partly.
The weird thing is: as you can see the animation group is attached to the frame - not to the texture or the fontstring. So why is one scaled and the other is not??

Whats wrong with my code?
Or is the animation group just another buged Blizzard feature?

Last edited by Duugu : 03-18-11 at 05:40 PM.
  Reply With Quote
03-19-11, 01:47 AM   #2
Akkorian
A Flamescale Wyrmkin
 
Akkorian's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 111
Hi Duugu,

I think the problem is that you set the font string to be size 30, and WoW won’t render text much bigger than that (the point size depends on the font file, but there is an maximum “physical” size limitation built into the game), even if you try to scale it. If you want the font to be that big, you can only scale it smaller.

Also, you only need one animation to get a “pulse” effect. Just set the looping type on the animation group to “BOUNCE” instead of “REPEAT”. You only need two animations if you want the “scale up” and “scale down” animations to happen at different speeds.

I wasn’t sure why you put in a start delay on your second animation, so I left that out, but if you wanted it to pause between the “scale up” and “scale down” animations you should use the SetEndDelay or SetStartDelay method on the animation. Actually I think you were trying to make it run one animation and then the other, which is what the animation:SetOrder method is for.

Here’s what I got working:
Lua Code:
  1. local tframe = CreateFrame("Frame", "testframe", UIParent)
  2. tframe:SetWidth(200)
  3. tframe:SetHeight(200)
  4. tframe:SetPoint("CENTER", UIParent, "CENTER")
  5.  
  6. local Texture = tframe:CreateTexture(nil,"OVERLAY")
  7. Texture:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background")
  8. Texture:SetWidth(200)
  9. Texture:SetHeight(200)
  10. Texture:SetPoint("BOTTOM")
  11.  
  12. local tFS = tframe:CreateFontString(nil, "OVERLAY")
  13. tFS:SetFont("Fonts\\FRIZQT__.TTF", 30, "OUTLINE")
  14. tFS:SetText("TestString")
  15. tFS:SetPoint("BOTTOM")
  16.  
  17. local ag = tframe:CreateAnimationGroup()
  18. ag:SetLooping("BOUNCE")
  19.  
  20. local a2 = ag:CreateAnimation("Scale")
  21. a2:SetScale(0.66, 0.66)
  22. a2:SetDuration(1)
  23. a2:SetSmoothing("NONE")
  24.  
  25. ag:Play()

I also took out the lines that weren’t needed. Things are shown by default when you create them, and font strings default to white.

I did notice that WoW doesn’t scale font strings very well. It isn’t very smooth, and it seems to scale it relative to the bottom left of the font string no matter how it’s anchored.

Also, it wouldn’t make your code not work, but you had both animation groups assigned to the local variable “a2”.

Hope that helps!
__________________
“Be humble, for you are made of earth. Be noble, for you are made of stars.”
  Reply With Quote
03-19-11, 02:13 PM   #3
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Thank you so much for straighten this. It explains at least something.

My primary goal was to create an animation with three or more animations which do not repeat. The loop was a dirty solution to demonstrate the animation's effect. SetOrder() fixed that problem.

So my new test code is like
lua Code:
  1. local tframe = CreateFrame("Frame", "testframe", UIParent)    
  2.     tframe:SetWidth(200)
  3.     tframe:SetHeight(200)
  4.     tframe:SetPoint("CENTER", UIParent, "CENTER", -400, 0)
  5.  
  6.     local Texture = tframe:CreateTexture(nil,"OVERLAY")
  7.     Texture:SetWidth(200)
  8.     Texture:SetHeight(200)
  9.     Texture:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background")
  10.     Texture:ClearAllPoints()
  11.     Texture:SetPoint("CENTER", tframe,"CENTER")
  12.  
  13.     local tFS = tframe:CreateFontString("PeonManagerWorldMapFontLayerLevelName", "OVERLAY")        
  14.     tFS:SetFont("Fonts\\FRIZQT__.TTF", 30, "OUTLINE, MONOCHROME")
  15.     tFS:SetText("TestString")
  16.     tFS:SetPoint("BOTTOM", tframe, "BOTTOM")    
  17.    
  18.     local ag = tframe:CreateAnimationGroup()
  19.  
  20.     --scale to 200% of original size
  21.     local a1 = ag:CreateAnimation("Scale")
  22.     a1:SetOrder(1)
  23.     a1:SetScale(2,2)
  24.     a1:SetDuration(4)
  25.     a1:SetSmoothing("NONE")
  26.  
  27.     -- scale to 25% of 200% = 50% of original size
  28.     local a2 = ag:CreateAnimation("Scale")
  29.     a2:SetOrder(2)
  30.     a2:SetScale(0.25, 0.25)
  31.     a2:SetDuration(4)
  32.     a2:SetSmoothing("NONE")
  33.  
  34.     -- scale to 200% of 50% = 100% of original size
  35.     local a3 = ag:CreateAnimation("Scale")
  36.     a3:SetOrder(3)
  37.     a3:SetScale(2, 2)
  38.     a3:SetDuration(4)
  39.     a3:SetSmoothing("NONE")
  40.  
  41.     ag:SetLooping("REPEAT")
  42.     ag:Play()

Unfortunately there two remaining problems:

1. The fontstring animation is still broken. The animation a) starts for every single animation with the original fontstring (in contrast to the texture animation, which scales as expected), and b) the fontstring animation ignores any anchors (as you said).
Alltogether this makes the animation stuff useless for fontstrings. Guess I'll have to replace all fontstrings by pre-build textuers. Horrible.

2. The texture's animation works as expected ... except the speed of animation three. IMO the third animation is much slower than speed of animation one and two. Isn't it? But I can't see why.

Thanks again for you valuable help.

Last edited by Duugu : 03-19-11 at 02:33 PM.
  Reply With Quote
03-20-11, 02:47 AM   #4
Akkorian
A Flamescale Wyrmkin
 
Akkorian's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 111
Originally Posted by Duugu View Post
The animation a) starts for every single animation with the original fontstring (in contrast to the texture animation, which scales as expected),
That’s because font strings can’t be scaled to make them bigger than the maxmium size WoW will render them. Since your font string is already at the maximum size when you create it, the animation can’t make it any bigger. If you start out with a smaller font string, it should scale up.

Originally Posted by Duugu View Post
the fontstring animation ignores any anchors (as you said).
You could adjust the anchoring yourself in an OnUpdate script attached to the animation.

Originally Posted by Duugu View Post
the third animation is much slower than speed of animation one and two
I didn’t notice anything weird with the speed of the animations on the texture, but the font string animation definitely doesn’t work right. It might be because of the scaling issue. Try playing around with different font sizes and scales so that it never gets bigger than 30, and see if that helps.
__________________
“Be humble, for you are made of earth. Be noble, for you are made of stars.”
  Reply With Quote
03-20-11, 02:27 PM   #5
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Tried it with smaller font sizes. No effect. The frontstring animation is definitely broken.

The OnUpdate idea sounds like it could work. But it seems to be a lot of work and the animation would be still ugly.
I'll skip the fontstring and use pre-rendered textures instead.

Thanks again for you valuable help Akkorian.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Whats wrong with the =(/§%ing AnimationGroup widget?


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