Quantcast WoWInterface - View Single Post - reliably setting color of frames
View Single Post
02-07-20, 05:05 AM   #1
sotdumm
A Kobold Labourer
Join Date: Feb 2020
Posts: 1
Question reliably setting color of frames

Hey,

I am working on a study project. I am creating multiple colored frames and I am trying to make them change their color.
I have tried to methods, the first one setting the color via SetTexture and then using SetColorTexture to change the color of the texture on the frame. This is very unreliable, (maybe I am initalising the farmes incorrectly...?) but they sometimes dont show up, or show up in black without the color changing. Doing a couple of /reload fixes them but, its a very undeterministic behaviour. They show up as white, but doesn't change. Code for this one, they somehow get stuck with being white:
Code:
local frame = CreateFrame("Frame", k, UIParent)
    frame:SetPoint("TOPLEFT", x, heightFromCorner)
    frame:SetHeight(BOX_SIZE)
    frame:SetWidth(BOX_SIZE)

      frame.texture = frame:CreateTexture()
      frame.texture:SetAllPoints(frame)
      frame.texture:SetColorTexture(1,1,1,1)
     frame:Show()
frame:SetScript(
    "OnUpdate",
    function(self, event)
        SetPlayerHealth(GetPlayerHealth())
    end
The other method that I have tried was using SetBackdrop but that way the frames show up as green. I am trying to load a simple background texture, so it should be loadable, doing it like this:
Code:
frame:SetBackdrop({
      bgFile = [[Interface\AddOns\myaddon\data\backdrop.tga]],
      insets = {top = 0, left = 0, bottom = 0, right = 0},
      })
I suspect something is off with the way I am trying to update the color of the frames, but since I assign a callback to the OnUpdate event, the update should be handled correctly.

Can you give any insights to this?

Thank you
  Reply With Quote