View Single Post
06-13-14, 02:28 PM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,327
Originally Posted by ImportedDj View Post
Lua Code:
  1. --Create a Frame for UI to be placed in
  2.  
  3. local pFrame = CreateFrame("Frame",ShowUF,UIParent)
  4.  
  5. local ufTexture = pFrame:CreateTexture()
  6. ufTexture:SetPoint("BOTTOM")
  7. ufTexture:SetTexture("Interface\\AddOns\\WoWUI\\Background\\BgIMG")
  8. pFrame:texture = ufTexture -- Line 8 regarding error
  9.  
  10.  
  11. pFrame:SetSize(1920,490)
  12. pFrame:Show()
Here's some comments I have about the posted code.
  • Line 3: Unless you have a variable named ShowUF, the frame will not have a name set as the variable will be nil. You should use a string here like "ShowUF".
  • Line 5: You should have a layer set for the texture. As you're trying to load a background, I suggest using the BACKGROUND layer. Note, you can set the name argument to nil if you don't want to set a name to the texture. (See http://wowpedia.org/API_Frame_CreateTexture)
    Example: pFrame:CreateTexture(nil,"BACKGROUND")
  • Line 8: pFrame:texture needs to be pFrame.texture. The colon is only used when calling a function that needs a reference to the table it's stored in.
  • Line 11: Keep in mind at UI scale 1.0, the game tries to render the UI at 1024x768 regardless of the display settings. The width may vary depending on the game window's aspect ratio, but the height is fixed.
  • Line 12: pFrame has no anchors set and won't show without one.
Also note, when you don't set the size of a texture object, it'll default to the image's dimensions.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 06-13-14 at 02:34 PM.
  Reply With Quote