StatusBar texcoord

Hello everyone, how are you?

I need a little help with an addon, and thanks in advance for any help.

I’m trying to make a time bar for buffs, and I tried using the default image UICastingBar2x.blp. The problem is that i can’t use part of the image as we naturally do in other textures, using SetTexCoord, it dont work. I tried to edit it in photoshop but there is a blank part left because it is not exactly, for example, 256 x 32, so when filling the bar, it goes beyond the border. Here’s the code I’m trying:

local BD = {
	bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
	tile = true,
	tileSize = 32,
	insets = {left = -1, right = -1, top = -1, bottom = -1},
}

local eventFrame = CreateFrame("Frame", nil, nil)
	
	eventFrame:RegisterEvent"PLAYER_ENTERING_WORLD"

local timerBar = CreateFrame("StatusBar", nil, UIParent, "BackdropTemplate")
timerBar:SetPoint("CENTER", UIParent, "TOP", 0, -100)
timerBar:SetSize(256, 9)
-- timerBar:SetStatusBarTexture("Interface\\CastingBar\\UICastingBar2x.BLP", "BORDER")
-- timerBar:SetStatusBarTexture("Interface\\AddOns\\Cooldown\\Bar", "BORDER")
-- timerBar:SetStatusBarColor(.0,1,1)
timerBar:SetBackdrop(BD)
timerBar:Hide()


local tex = timerBar:CreateTexture(nil, "ARTWORK")
tex:SetTexture"Interface\\AddOns\\Cooldown\\Bar"
tex:SetAllPoints()
timerBar:SetStatusBarTexture(tex)

tex:SetTexCoord(0.1, 0.9, 0.1, 0.9)

timerBar.Border = timerBar:CreateTexture(nil, "ARTWORK")
-- timerBar.Border:SetTexture"Interface\\CastingBar\\UI-CastingBar-Border"
timerBar.Border:SetTexture"Interface\\AddOns\\Cooldown\\Border_512"
timerBar.Border:SetSize(256, 16)
timerBar.Border:SetPoint("CENTER", timerBar, 0, 0)
timerBar:Show()
local BD = {
	bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
	tile = true,
	tileSize = 32,
	insets = {left = -1, right = -1, top = -1, bottom = -1},
}

local eventFrame = CreateFrame("Frame", nil, nil)
	
	eventFrame:RegisterEvent"PLAYER_ENTERING_WORLD"

local timerBar = CreateFrame("StatusBar", nil, UIParent, "BackdropTemplate")
timerBar:SetPoint("CENTER", UIParent, "TOP", 0, -100)
timerBar:SetSize(256, 9)
timerBar:SetStatusBarTexture("Interface\\CastingBar\\UICastingBar2x.BLP", "BORDER")

-- get the texture
local t = timerBar:GetStatusBarTexture()
-- use the casting bar atlas
t:SetAtlas("ui-castingbar-filling-standard",true)

timerBar:SetBackdrop(BD)
timerBar:Hide()

timerBar.Border = timerBar:CreateTexture(nil, "ARTWORK")
-- timerBar.Border:SetTexture"Interface\\CastingBar\\UI-CastingBar-Border"
timerBar.Border:SetTexture"Interface\\AddOns\\Cooldown\\Border_512"
timerBar.Border:SetSize(256, 16)
timerBar.Border:SetPoint("CENTER", timerBar, 0, 0)
timerBar:Show()

2 Likes

Hey, Fizz,
what would we do without you. ty very much!

I would love it if you could help me with another question, what i would like to do is copy the new casting bar, for example, for a mount cast bar.

With the example you gave me, i couldn’t place the border, i tried with the code below, but it was distorted, no matter what size i set.

Could you help me make an identical blizzard bar?
I think the new bars are very pretty.

And one last question, would it be possible to copy the animations that blizzard uses or would that be very difficult?

The code:
PS.: i dont care about this code, if you bring a new one, its ok.

local BD = {
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
tile = true,
tileSize = 32,
insets = {left = -1, right = -1, top = -1, bottom = -1},

}

local eventFrame = CreateFrame(“Frame”, nil, nil)

eventFrame:RegisterEvent"PLAYER_ENTERING_WORLD"

local timerBar = CreateFrame(“StatusBar”, nil, UIParent, “BackdropTemplate”)
timerBar:SetPoint(“CENTER”, UIParent, “CENTER”, 0, -350)
timerBar:SetSize(207, 11)
timerBar:SetStatusBarTexture(“Interface\CastingBar\UICastingBar2x.BLP”, “BORDER”)

– get the texture
local t = timerBar:GetStatusBarTexture()
– use the casting bar atlas
t:SetAtlas(“ui-castingbar-filling-standard”,true)

– timerBar:SetBackdrop(BD)
timerBar:Hide()

local timerBar.Border = timerBar:CreateTexture(nil, “ARTWORK”)
timerBar.Border:SetTexture"Interface\CastingBar\UI-CastingBar-Border-Small"
timerBar.Border:SetSize(280, 45 )
timerBar.Border:SetPoint(“CENTER”, timerBar, 0, 0)
timerBar:Show()

– get the texture
local tb = timerBar.Border:GetStatusBarTexture()
– use the casting bar atlas
tb:SetAtlas(“UI-CastingBar-Background”,true)

For the border maybe get rid of the background and just use something like:

local eventFrame = CreateFrame("Frame", nil, nil)
	
	eventFrame:RegisterEvent"PLAYER_ENTERING_WORLD"

local timerBar = CreateFrame("StatusBar", nil, UIParent) --, "BackdropTemplate")
timerBar:SetPoint("CENTER", UIParent, "TOP", 0, -100)
timerBar:SetSize(256, 9)
timerBar:SetStatusBarTexture("Interface\\CastingBar\\UICastingBar2x.BLP", "BORDER")

-- get the texture
local t = timerBar:GetStatusBarTexture()
-- use the casting bar atlas
t:SetAtlas("ui-castingbar-filling-standard",true)
timerBar:Hide()

timerBar.Border = timerBar:CreateTexture(nil, "BACKGROUND")
timerBar.Border:SetPoint("TOPLEFT", -3, 3)
timerBar.Border:SetPoint("BOTTOMRIGHT", 3, -3)
timerBar.Border:SetAtlas("castbar_shadow_embedded")
timerBar:Show()

You can certainly copy animations from Blizz. code and apply them to your own frames/textures. With complicated ones it can take a bit of figuring out what each one is doing and how they work together.

There are also casting bar templates you can inherit eg.
SmallCastingBarFrameTemplate, CastingBarFrameTemplate with a lot of the animations defined in: CastingBarFrameAnimsFXTemplate

1 Like

Perfect, Fizz!

You have been helping the community and me for many years!
Ty so much!

1 Like