Thread Tools Display Modes
05-13-11, 02:58 PM   #1
feraldrood
A Theradrim Guardian
 
feraldrood's Avatar
Join Date: Dec 2008
Posts: 62
Animated Statusbars

Hi all,

please observe the statusbars used in "SpartanUI"

http://spartanui.com/index.html

m'kay, so I'm wondering how the animated health/power (bar) texture is achieved, and more importantly how I could achieve a similar effect on any statusbar.

thanks for any of help your help folks.
  Reply With Quote
05-13-11, 03:35 PM   #2
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Looking at google code oUF is used, which probably does not have the animated look.

Roth UI however is updated regularly and provides a more up to date way to have animated statusbars (at least for the player frame, that is).

EDIT: This got me thinking.

From a developer point of view, one could create a statusbar and change the texture with :SetTexCoords() by an OnUpdate handler/statusbar OnValueChanged(to prevent stupid stretched textures) script. The statusbar texture should be with, like 36 bar sprites or something(all aligned horizontally and in a vertical column)?

Code could be something like this maybe? (not tested)
lua Code:
  1. local OnUpdate, UpdateRight
  2. do
  3.     -- Time since last update
  4.     local tslu = 0
  5.     -- which sprite on the texture should be set
  6.     local lastsprite = 1
  7.     -- Number of sprites
  8.     local maxsprites = 36
  9.     -- Updates per second,
  10.     -- number of sprites percentage of texture height per sprite
  11.     local ups = 1/maxsprites
  12.     -- right, to prevent stretched textures.
  13.     local right = 1
  14.    
  15.     function UpdateRight(self, value)
  16.         local min, max = self:GetMinMaxValues()
  17.         right = (value - min) / (max - min)
  18.     end
  19.    
  20.     function OnUpdate(self, elapsed)
  21.         tslu = tslu + elapsed
  22.         if tslu > ups then
  23.             -- Determine which sprite needs to be loaded
  24.             -- Account for a framerate lower then maximum sprites
  25.             local sprite = lastsprite + math.floor(elapsed/ups)
  26.             -- Adjust statusbar texture to sprite
  27.             if sprite > maxsprites then
  28.                 sprite = sprite - maxsprites
  29.             end
  30.             self:GetStatusBarTexture():SetTexCoord(0, right, (sprite * ups) - ups, sprite * ups)
  31.             -- Wait for next update again
  32.             tslu = 0
  33.             lastsprite = sprite
  34.         end
  35.     end
  36. end
  37.  
  38. local bar = CreateFrame('StatusBar', nil, UIParent)
  39. bar:SetMinMaxValues(0,1)
  40. bar:SetScript('OnValueChanged', UpdateRight)
  41. bar:SetScript('OnUpdate', OnUpdate)
  42. bar:SetValue(1)

Last edited by ravagernl : 05-13-11 at 04:13 PM.
  Reply With Quote
05-13-11, 04:52 PM   #3
feraldrood
A Theradrim Guardian
 
feraldrood's Avatar
Join Date: Dec 2008
Posts: 62
hmm.

i'm intrigued , the coding is a little over my lua experience but your thought process sounds about right. thanks for the reply, i'll be chipping away at this all day :3

btw, ofc- roths stuff is totally what I'm talking about (didn't even occur to me)

I'll examine his codes a little bit too perhaps
  Reply With Quote
05-13-11, 05:18 PM   #4
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
Could probably look at the Smooth plugin for oUF as well.

http://www.wowinterface.com/download...othUpdate.html
__________________
Oh, the simulated horror!
  Reply With Quote
05-14-11, 04:26 AM   #5
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
That is what Roth UI uses aswell. (SmoothUpdate)
__________________
| 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

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Animated Statusbars


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