Thread Tools Display Modes
07-16-15, 09:04 AM   #1
lynce
A Cyclonian
 
lynce's Avatar
Join Date: Jul 2008
Posts: 48
Animate textures

Anyone got any knowledge on how to animate textures, say like a healthbar texture, in oUF?
  Reply With Quote
07-16-15, 09:42 AM   #2
Munglunch
Premium Member
 
Munglunch's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Jun 2009
Posts: 34
Originally Posted by lynce View Post
Anyone got any knowledge on how to animate textures, say like a healthbar texture, in oUF?
What exactly did you have in mind?
  Reply With Quote
07-16-15, 01:12 PM   #3
lynce
A Cyclonian
 
lynce's Avatar
Join Date: Jul 2008
Posts: 48
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.
  Reply With Quote
07-17-15, 01:57 AM   #4
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Originally Posted by lynce View Post
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.
__________________
  Reply With Quote
07-17-15, 03:54 AM   #5
lynce
A Cyclonian
 
lynce's Avatar
Join Date: Jul 2008
Posts: 48
I see. Thanks.

Hm looks quite complicated:P
  Reply With Quote
07-17-15, 06:05 AM   #6
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Originally Posted by lynce View Post
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 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.
__________________
  Reply With Quote
07-17-15, 06:21 AM   #7
lynce
A Cyclonian
 
lynce's Avatar
Join Date: Jul 2008
Posts: 48
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
  Reply With Quote
07-17-15, 11:46 AM   #8
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Originally Posted by lynce View Post
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
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.
__________________

Last edited by lightspark : 07-17-15 at 11:50 AM.
  Reply With Quote
07-17-15, 12:02 PM   #9
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
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

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)
__________________

Last edited by lightspark : 07-17-15 at 12:05 PM.
  Reply With Quote
07-19-15, 12:48 AM   #10
lynce
A Cyclonian
 
lynce's Avatar
Join Date: Jul 2008
Posts: 48
Thanks again lightspark
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Animate textures


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