WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Creating frames with text (https://www.wowinterface.com/forums/showthread.php?t=56143)

CrittenxD 04-08-18 08:02 PM

Creating frames with text
 
EDIT: Thanks a lot, I reworked everything and I'm now using the same frame. Thread done.

Fizzlemizz 04-08-18 09:06 PM

Text stacking on top of each other usually means you are creating a new frame/fontstring each time you call the function when you want to re-use existing frames as much as possible. Something like:
Lua Code:
  1. local f1 = CreateFrame("Frame",nil,UIParent)
  2. f1:SetWidth(1)
  3. f1:SetHeight(1)
  4. f1:SetAlpha(.90);
  5. f1:SetPoint("CENTER",650,-100)
  6. f1.text = f1:CreateFontString(nil,"ARTWORK")
  7. f1.text:SetFont("Fonts\\ARIALN.ttf", 13, "OUTLINE")
  8. f1.text:SetPoint("CENTER",0,0)
  9. f1:Hide()
  10.  
  11. local f2 = CreateFrame("Frame",nil,UIParent)
  12. f2:SetWidth(1)
  13. f2:SetHeight(1)
  14. f2:SetAlpha(.90);
  15. f2:SetPoint("CENTER",650,-100)
  16. f2.text = f2:CreateFontString(nil,"ARTWORK")
  17. f2.text:SetFont("Fonts\\ARIALN.ttf", 13, "OUTLINE")
  18. f2.text:SetPoint("CENTER",0,0)
  19. f2:Hide()
  20.  
  21. local function displayupdate(show, message)
  22.     if show == 1 then
  23.         f1.text:SetText(message)
  24.         f1:Show()
  25.         f2:Hide()
  26.     elseif show == 2 then
  27.         f2.text:SetText(message)
  28.         f2:Show()
  29.         f1:Hide()
  30.     else
  31.         f1:Hide()
  32.         f2:Hide()
  33.     end
  34. end
  35.  
  36. displayupdate(1, "|cffffffffmyobjective1")
  37. --or
  38. displayupdate(2, "|cffffffffmyobjective2")
  39. --or
  40. displayupdate() -- to just hide both
  41. --or possibly display both objectives in the one fontstring
  42. displayupdate(1, "myobjective1\nmyobjective2")
  43.  
  44. --To use variables:
  45. local objective1 = "myobjective1"
  46. local objective2 = "myobjective2"
  47. displayupdate(1, objective1.."\n"..objective2)

If you are just creating a mechanism to display a changing message then you probably only need one frame.


All times are GMT -6. The time now is 01:39 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI