View Single Post
12-18-23, 09:07 AM   #10
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,897
In RedSquareTest you have
Code:
<Layer setAllPopints="tue" color=...
A Layer describes the DrawLayer it's children will apear in in the parent frame.

The actual square would have to be a
Code:
<Texture ...
element with a size and anchor to place it within the frame.

The same with the CreateFrame version. It would require

Code:
RedSquareTest.Texture = RedSquareTest:CreateTexture(nil, "BACKGROUND")
RedSquareTest.Texture:SetAllPoints()
RedSquareTest.Texture:SetColorTexture(1, 0, 0)
As an aside, where you are using frame = ... you should use local frame = ... (unless you are re-using a previously created local) otherwise you are creating the varable as a global which (if using simple variable names) could overwrite a global from another addon or the Blizzard UI (they all share the same global table and Blizzard will use simple or "meaningful" names for global variables and they use a LOT ot them).
If you need to create globals, make them unique and identifiable by adding something like the name/acronym of your addon (same goes for frame/region names as these are also added to the global table).

As an aside aside. You can use either XML or CreateFrame (in lua code) you don't need both (unless you are creating a virutal or an intrinsic which require XML). There is no real benefit from using one over the other apart from preference.

As an aside aside...aside. Where you use
Code:
local frame = CreateFrame(...)
You can then refer to the frame using frame (while it is in scope) rather than the frame's name. Not every frame/texture/fontstring etc. needs a name).
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 12-18-23 at 10:15 AM.
  Reply With Quote