Hi all,
Since yesterday, I have started to create my own unitframe with oUF which I am feeling a lot of fun
!!
I Just got some questions regarding frame creation(?).
Let's have a look at the code first:
Lua Code:
A.CreateHealth = function(f, unit)
A.CreateHealthBar(f, unit);
end
A.CreateHealthBar = function(f, unit)
local Health = CreateFrame("StatusBar", f:GetName() .. "HealthBar", f);
Health:SetStatusBarTexture(HEALTH_BAR);
Health:SetStatusBarColor(0, 0, 0, 1);
Health:SetFrameLevel(3);
if unit == "player" then
Health:SetPoint("TOPRIGHT", f, "TOPRIGHT", -1, -1);
Health:SetSize(f:GetWidth() - 12, f:GetHeight() - 12);
end
local backdrop = CreateFrame("Frame", nil, Health);
backdrop:SetSize(Health:GetWidth() + 2, Health:GetHeight() + 2);
backdrop:SetPoint("CENTER");
backdrop:SetBackdrop({
edgeFile = BACKDROP,
edgeSize = 1,
});
backdrop:SetBackdropBorderColor(1, 0, 0, 1);
Health.bg = Health:CreateTexture(nil, "BACKGROUND");
Health.bg:SetAllPoints(true);
Health.bg:SetTexture(BACKDROP);
Health.bg:SetVertexColor(0.5, 0.5, 0.5, 1);
f.Health = Health;
f.Health.bg = Health.bg;
end
A.CreatePower = function(f, unit)
A.CreatePowerBar(f, unit);
end
A.CreatePowerBar = function(f, unit)
local Power = CreateFrame("StatusBar", f:GetName() .. "PowerBar", f);
Power:SetStatusBarTexture(HEALTH_BAR);
Power:SetStatusBarColor(1, 1, 1, 1);
Power:SetFrameLevel(2);
if unit == "player" then
Power:SetPoint("BOTTOMLEFT", f, "BOTTOMLEFT", 1, 1);
Power:SetSize(f:GetWidth() - 12, f:GetHeight() - 12);
end
local backdrop = CreateFrame("Frame", nil, Power);
backdrop:SetSize(Power:GetWidth() + 2, Power:GetHeight() + 2);
backdrop:SetPoint("CENTER");
backdrop:SetBackdrop({
edgeFile = BACKDROP,
edgeSize = 1,
});
backdrop:SetBackdropBorderColor(0, 0, 1, 1);
f.Power = Power;
end
The code above currently results in the following:
Health Bar - Black status bar with Red border and Grey background
Power Bar - White status bar with Blue border (currently have no background)
SO..... here's my question.
1. Would it be possible to create a border for status bar frame without creating another frame (which is called 'backdrop' in this case).
2. As you can see, Power Bar's border is sitting on top of the Health Bar's background. What would be the best solution to fix this problem?