WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Getting a texture on the screen (https://www.wowinterface.com/forums/showthread.php?t=49381)

ImportedDj 06-12-14 11:13 AM

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.

semlar 06-12-14 12:38 PM

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.

SDPhantom 06-13-14 02:28 PM

Quote:

Originally Posted by ImportedDj (Post 293333)
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.


All times are GMT -6. The time now is 10:58 PM.

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