Rotation animations in Dragonflight - WoWInterface
Thread Tools Display Modes
12-04-22, 04:05 PM   #1
A Fallenroot Satyr
Join Date: Mar 2008
Posts: 20
Rotation animations in Dragonflight

I'm having problems with a personal project that was working just fine in 9.1, involving animations, specifically rotation.

It seems to me that the :SetOrigin function works very differently than before or is broken in some way, here is a reproducer:

local duration = 2.0;
local width = 50;

local center = CreateFrame("frame", UIParent);
center:SetPoint("CENTER", 0, 0)
center:SetSize(2, 2);
local centerTex = center:CreateTexture();
centerTex:SetColorTexture(1, 0, 0, .9);

local frame = CreateFrame("frame", UIParent);
frame:SetPoint("LEFT", UIParent, "CENTER", 0, 0)
frame:SetSize(width, width * 2);

local tex = frame:CreateTexture();
tex:SetColorTexture(0, 1, 0, .2);

local ag = frame:CreateAnimationGroup();

local rot0 = ag:CreateAnimation("Rotation");
rot0:SetOrigin("LEFT", 0.1, 0); -- try -.1, 0, .1
rot0:HookScript("OnFinished", function(...) ag:Pause(); end);

print("Scale: ", frame:GetEffectiveScale());
See the line "rot0:SetOrigin("LEFT", 0.1, 0); -- try -.1, 0, .1", and I'm already very conservative with those values here, using 1 or -1, the texture is off-screen in half a second. Also it prints "Scale: 1"

Any ideas what's going on here would be appreciated
  Reply With Quote
12-05-22, 03:07 AM   #2
A Pyroguard Emberseer
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Check for the Blizzard API documentation.


Specifically look into the SimpleAnimAPI. Maybe you can simplify your code using the new API and your problem vanishes on its own.
| 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
12-05-22, 02:14 PM   #3
A Fallenroot Satyr
Join Date: Mar 2008
Posts: 20
How do I get a "SimpleAnimRotationAPI" or I guess "SimpleAnimationGroupAPI" object?

PS: the API looks identical to the normal animation API, what's the difference?
  Reply With Quote
12-07-22, 04:50 PM   #4
A Fallenroot Satyr
Join Date: Mar 2008
Posts: 20
Alright, still no idea how to use the Simple* APIs, I have in the meantime found a hint to the issue here, but this is the best I've managed to get:
Click image for larger version

Name:	ezgif-5-420024f73e.gif
Views:	33
Size:	673.0 KB
ID:	9773
(sorry, open original, forum compression is terrible)

The red and blue dots should be on the LEFT and RIGHT points of the rectangle (capture starts somewhere in the middle of the animation) and the rectangle is supposed to rotate around the RIGHT point.

Basically what I used is:

offset_x_fixed = offset_x * width / UIParent:GetWidth();
But you can see that's not 100% correct, it's still "wobbly"
  Reply With Quote
12-07-22, 09:42 PM   #5
I did that?
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,633
Maybe (if the above is the effect you're looking for):
Lua Code:
  1. local duration = 2.0;
  2. local width = 50;
  4. local center = CreateFrame("frame", UIParent); -- the red square
  5. center:SetPoint("CENTER", 0, 0)
  6. center:SetSize(2, 2);
  7. local centerTex = center:CreateTexture();
  8. centerTex:SetColorTexture(1, 0, 0, .9);
  9. centerTex:SetAllPoints(center);
  11. local frame = CreateFrame("frame", UIParent); -- Host for the AnimationGroup and anchor for the rotating texture
  12. frame:SetSize(1, 1)
  13. frame:SetPoint("CENTER", center, "CENTER", 0, 0)
  15. local tex = frame:CreateTexture(); -- Rotation animation (rot0) SetChildKey targets this texture to rotate
  16. frame.tex = tex                       -- through this key
  17. tex:SetColorTexture(0, 1, 0, .2);
  18. --tex:SetAllPoints(frame);
  19. tex:SetSize(width, width * 2)
  20. tex:SetPoint("LEFT", frame, "CENTER")
  22. local ag = frame:CreateAnimationGroup();
  23. ag:SetLooping("REPEAT")
  25. local rot0 = ag:CreateAnimation("Rotation");
  26. rot0:SetChildKey("tex")
  27. rot0:SetDegrees(360);
  28. rot0:SetDuration(duration);
  29. rot0:SetEndDelay(0);
  30. rot0:SetOrigin("LEFT", 0, 0);
  31. ag:Play();
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 12-08-22 at 12:56 AM.
  Reply With Quote
12-08-22, 04:53 AM   #6
A Fallenroot Satyr
Join Date: Mar 2008
Posts: 20
Thanks for the attempt, but I need to rotate around an origin that is not on the edge of the texture (could just use "RIGHT" otherwise), I only used a point on the edge of the rectangle because that makes it easier to verify whether the rotation is correct.

I've in the meantime not been able to find an object with dimensions so that there is no wobble, but I'm fairly sure it has to somwhow correspond to the viewport or UIParent, maybe there are also just precision issues due to all the scaling going on.

I've decided to switch to using a mask texture, which is an option in my case and hopefully won't even require the use of any animations, as using animations was a workaround in the first place.
  Reply With Quote
12-31-22, 06:02 AM   #7
A Fallenroot Satyr
Join Date: Mar 2008
Posts: 20
Despite having fixed the issue I was facing, I would still like to know if there was an actual solution, as the previous implementation was much more flexible, for example it allowed me to mirror the texture, now I have to have an actually mirrored texture file
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Rotation animations in Dragonflight

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