WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Rotation animations in Dragonflight (https://www.wowinterface.com/forums/showthread.php?t=59391)

watchout 12-04-22 04:05 PM

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:

Code:

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);
centerTex:SetAllPoints(center);

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);
tex:SetAllPoints(frame);

local ag = frame:CreateAnimationGroup();

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

print("Scale: ", frame:GetEffectiveScale());
ag:Play();

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

zork 12-05-22 03:07 AM

Check for the Blizzard API documentation.

https://www.townlong-yak.com/framexm...IDocumentation

Specifically look into the SimpleAnimAPI. Maybe you can simplify your code using the new API and your problem vanishes on its own.

watchout 12-05-22 02:14 PM

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?

watchout 12-07-22 04:50 PM

1 Attachment(s)
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:
Attachment 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:

Code:

offset_x_fixed = offset_x * width / UIParent:GetWidth();
But you can see that's not 100% correct, it's still "wobbly"

Fizzlemizz 12-07-22 09:42 PM

Maybe (if the above is the effect you're looking for):
Lua Code:
  1. local duration = 2.0;
  2. local width = 50;
  3.  
  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);
  10.  
  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)
  14.  
  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")
  21.  
  22. local ag = frame:CreateAnimationGroup();
  23. ag:SetLooping("REPEAT")
  24.  
  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();

watchout 12-08-22 04:53 AM

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.

watchout 12-31-22 06:02 AM

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


All times are GMT -6. The time now is 12:35 PM.

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