you can use actually xml
or lua to create a frame, and in this case you are actually doing the same creation job twice — overwriting whichever of the first you load by reusing the same name across your two files.
I personally find pure lua implementation to be a much cleaner and more effective method with less overhead, so I'd recommend:
- Code: Select all
local f = CreateFrame("customframe", nil, UIParent)
f:SetFrameStrata("BACKGROUND")
f:SetWidth(128)
f:SetHeight(64)
f:SetPoint("CENTER", 0, 0)
f:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]]})
f:SetBackdropColor(0, 0, 0, 1)
local t = f:CreateTexture(nil,"BACKGROUND")
t:SetTexture("blablabla.tga")
t:SetAllPoints()
f.texture = t
no need to call Show() as that is the default state on a frames creation. you can also call SetAllPoints() without an argument focus like this, and it'll default to the point references of the childs parent.
finally — you've not created a function or any kind of scoping, so no need to drop an 'end' at the foot of your file. that'll actually cause a lua error and is probably the reason your frame isn't showing up. i'd recommend turning on 'show lua errors' in your interface options if its currently toggled off.
someone else can probably give you a better overview of xml usage.
e: also note that custom textures have some rules that need to be followed — the most important of which is that the image must be saved at a size that is a power of 2 (2px, 4px, 8px, 16px, 32px, 64px, 128px etc.). i've taken the liberty of adding two more lines that add a simple backdrop to the frame (similar to that applied to tooltips or other blizzard elements), which will show up if the frame is created but your texture fails to successfully appear, for bug testing. you can remove those lines again once it is sorted.