Thread Tools Display Modes
06-12-14, 11:13 AM   #1
ImportedDj
A Deviate Faerie Dragon
Join Date: Jun 2014
Posts: 10
Getting a texture on the screen

Hi all, I am currently trying to populate the screen with a test image however it doesnt seem to appear on the screen.. i have tried the follow with buggrabber and bugsack.

Code:
--Create a Frame for UI to be placed in

local pFrame = CreateFrame("Frame",ShowUF,UIParent)

local ufTexture = pFrame:CreateTexture()
ufTexture:SetPoint("BOTTOM")
ufTexture:SetTexture("Interface\\AddOns\\WoWUI\\Background\\BgIMG")
pFrame:texture = ufTexture - Line 8 regarding error


pFrame:SetSize(1920,490)
pFrame:Show()
however i get the following error
Code:
TestOne.lua:8: function arguments expected near "="
Removing the code that brings this error removes all errors in the code, however the image is still not being placed onto the screen.. if anyone is able to help i'd greatly appreciate it.
  Reply With Quote
06-12-14, 12:38 PM   #2
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
The error is from "pFrame:texture", which is only proper syntax is you're trying to call "texture()" like a method of pFrame.

If you're assigning "texture" as a key in the pFrame table you use the dot like "pFrame.texture = ufTexture" instead of the colon.

It doesn't really have anything to do with the texture showing on screen though, you aren't giving the texture a size so start with that. You can do ufTexture:SetAllPoints() to attach it everywhere on pFrame or ufTexture:SetSize(1920,490) or something.
  Reply With Quote
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,313
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

WoWInterface » Developer Discussions » Lua/XML Help » Getting a texture on the screen

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