Thread Tools Display Modes
04-08-18, 08:02 PM   #1
CrittenxD
A Deviate Faerie Dragon
Join Date: Apr 2018
Posts: 13
Creating frames with text

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

Last edited by CrittenxD : 04-15-18 at 01:10 PM.
  Reply With Quote
04-08-18, 09:06 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
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.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 04-09-18 at 12:15 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Creating frames with text

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off