Thread Tools Display Modes
10-29-12, 06:47 PM   #1
indoviet
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Jan 2009
Posts: 8
Placing 2 frames side by side

Hi, I'm running into some problems when trying to place 2 frames side by side. This is an excerpt from my code:

Code:
	IconFrame1 = CreateFrame("Frame", nil, MainFrame)
	IconFrame1:SetSize(40,40)
	IconFrame1:SetPoint("TOPLEFT", MainFrame, "TOPLEFT")
	
	IconFrame2 = CreateFrame("Frame", nil, MainFrame)
	IconFrame2:SetSize(40,40)
	IconFrame2:SetPoint("TOPLEFT", IconFrame1, "TOPRIGHT")
	
	local texture = IconFrame1:CreateTexture(nil, "BACKGROUND")
	texture:SetAllPoints(true)
	texture:SetTexture("Interface\\Icons\\Ability_Warlock_Haunt")
	texture:SetTexCoord(0.07,0.9,0.07,0.90)
	
	local texture2 = IconFrame2:CreateTexture(nil, "BACKGROUND")
	texture:SetAllPoints(true)
	texture:SetTexture("Interface\\Icons\\Ability_Warlock_ChaosBolt")
	texture:SetTexCoord(0.07,0.9,0.07,0.90)
MainFrame is just a 80x40 frame I created earlier.

The problem that's occurring is IconFrame2 seems to be placed right on top of IconFrame1. That is, in-game, I see the Chaos Bolt icon where the Haunt icon should be. And if I remove the last 4 lines of code, I can see the Haunt texture.

I've spent a lot of time trying to debug the code and I've run out of ideas to fix this. Any help would be much appreciated. Thank you!
  Reply With Quote
10-29-12, 07:11 PM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Before Phanx comes in to tell you to post your whole code (there's good reason for that)
I'll say that the problem lies with how you make your MainFrame most probably (which we can't see from the snippet you provided)

Nothing jumps out at me from this code.

You can probably verify if your container frame is the issue by temporarily changing your parent to UIParent (anchor the first icon to CENTER if you like) and test what happens.

You could also do a :ClearAllPoints() before :SetPoint() your frames since parenting them to your container frame might be implicitly setting some points on them.

Last edited by Dridzt : 10-29-12 at 07:16 PM.
  Reply With Quote
10-29-12, 07:37 PM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
Originally Posted by indoviet View Post
Code:
	local texture = IconFrame1:CreateTexture(nil, "BACKGROUND")
	texture:SetAllPoints(true)
	texture:SetTexture("Interface\\Icons\\Ability_Warlock_Haunt")
	texture:SetTexCoord(0.07,0.9,0.07,0.90)
	
	local texture2 = IconFrame2:CreateTexture(nil, "BACKGROUND")
	texture:SetAllPoints(true)
	texture:SetTexture("Interface\\Icons\\Ability_Warlock_ChaosBolt")
	texture:SetTexCoord(0.07,0.9,0.07,0.90)
Your second set of code is overwriting what the first set is doing. It's acting on texture instead of texture2.
__________________
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)
  Reply With Quote
10-29-12, 07:46 PM   #4
indoviet
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Jan 2009
Posts: 8
... I think I found the problem. In the last 4 lines of code where I'm trying to set the attributes for texture2, I'm actually setting them for the original texture. Apologies for posting such a stupid question.

Thanks a lot for your help Dridzt, I actually found the error by following your suggestion which forced me to look at my code again.

-- Oh and didn't even see SDPhantom's response -____- Thanks again guys
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Placing 2 frames side by side


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