WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Animate textures (https://www.wowinterface.com/forums/showthread.php?t=52507)

lynce 07-16-15 09:04 AM

Animate textures
 
Anyone got any knowledge on how to animate textures, say like a healthbar texture, in oUF?

Munglunch 07-16-15 09:42 AM

Quote:

Originally Posted by lynce (Post 309819)
Anyone got any knowledge on how to animate textures, say like a healthbar texture, in oUF?

What exactly did you have in mind?

lynce 07-16-15 01:12 PM

Well i was sort of fascinated how SyncUI does animation on the unitframes. And i was wondering if someone have any experience doing this in oUF.

lightspark 07-17-15 01:57 AM

Quote:

Originally Posted by lynce (Post 309825)
Well i was sort of fascinated how SyncUI does animation on the unitframes. And i was wondering if someone have any experience doing this in oUF.

It has nothing to do with oUF or anything, it's done old school way and pretty simple. Basically it's just a slideshow, he has a texture with 60 "slides", and an OnUpdate script running for a statusbar, that goes through 60 slides.

lynce 07-17-15 03:54 AM

I see. Thanks.

Hm looks quite complicated:P

lightspark 07-17-15 06:05 AM

Quote:

Originally Posted by lynce (Post 309838)
I see. Thanks.

Hm looks quite complicated:P

It's really simple though. First you make a map of "slides", then you make a table of coordinates for each slide, in SyncUI case he has a table of 60 items. He has a function that continuously runs through this list for certain statusbars, as the result you have a fluid animation.

You can check his code in \SyncUI\Modules\Elements\StatusBar\StatusBar.lua file, table of coordinates is the biggest part of it :D Syncrow's code is pretty easy to read, so you shouldn't have any problems.

And that's his "slide" map \SyncUI\Media\Textures\Elements\Statusbar\StatusBar_Animated_Fluid.tga.

lynce 07-17-15 06:21 AM

Yes i have looked at it. But what i do not understand is how he uses this to represent his bars in the unitframes. Like where in the code:o

lightspark 07-17-15 11:46 AM

Quote:

Originally Posted by lynce (Post 309840)
Yes i have looked at it. But what i do not understand is how he uses this to represent his bars in the unitframes. Like where in the code:o

StatusBar.xml? Syncrow utilises xml-templates... Read code there...

He has a .Fill texture, that is used for animation, this particular texture is attached to statusbar texture. It's all written in the code there, please, read more carefully :3

Lua Code:
  1. function SyncUI_AnimatedStatusBar_OnLoad(self)
  2.     table.insert(framesToAnimate,self)
  3.     self.Fill:SetAllPoints(self:GetStatusBarTexture())
  4. end

Code:

<StatusBar name="SyncUI_AnimatedStatusBarTemplate" virtual="true">
        <Layers>
                <Layer level="BACKGROUND">
                        <Texture file="Interface\AddOns\SyncUI\Media\Textures\Elements\Statusbar\StatusBar_Background" />
                </Layer>
                <Layer level="ARTWORK">
                        <Texture parentKey="Fill" setAllPoints="true" file="Interface\AddOns\SyncUI\Media\Textures\Elements\Statusbar\StatusBar_Animated_Fluid" />
                </Layer>
        </Layers>
        <Scripts>
                <OnLoad function="SyncUI_AnimatedStatusBar_OnLoad" />
        </Scripts>
        <BarTexture />
</StatusBar>

He then creates a status bar, using template and thus inherits all options:

Code:

<StatusBar parentKey="HealthBar" name="$parentHealthBar" inherits="SyncUI_AnimatedStatusBarTemplate" useParentLevel="true" minValue="0" maxValue="100">
        <Size x="74" y="34"/>
        <Anchors>
                <Anchor point="TOPLEFT" x="5" y="-5"/>
        </Anchors>
</StatusBar>

Same can be done in pure lua or mixture of lua and xml.

lightspark 07-17-15 12:02 PM

Here's an example of a simplified lua implementation w/o xml-templates. A simple statusbar constructor, based on existing functions from StatusBar.lua.

Ofc you'll have to add some other code, cuz I dun intend to write everything for ya :D

Lua Code:
  1. local function CreateAnimatedStatusBar(parent, ...)
  2.     local bar = CreateFrame("StatusBar", "$parentStatusBar", parent)
  3.  
  4.     local fill = bar:CreateTexture(nil, "ARTWORK")
  5.     fill:SettAllPoints(bar:GetStatusBarTexture())
  6.     fill:SetTexture("Interface\\AddOns\\SyncUI\\Media\\Textures\\Elements\\Statusbar\\StatusBar_Animated_Fluid")
  7.     bar.Fill = fill
  8.  
  9.     tinsert(framesToAnimate, bar)
  10.  
  11.     return bar
  12. end
  13.  
  14. local AnimationController = CreateFrame("Frame")
  15. AnimationController:SetScript("OnUpdate", SyncUI_AnimatedStatusBarFrame_OnUpdate)

Then you spawn statusbars like so:
Lua Code:
  1. local healthbar = CreateAnimatedStatusBar(your_unit_frame)

lynce 07-19-15 12:48 AM

Thanks again lightspark:)


All times are GMT -6. The time now is 01:33 AM.

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