12.07.2015 Views

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 9 ■ Working with Frames, Widgets, <strong>and</strong> Other Graphical Elements 163Figure 9-11: BagBuddy after using SetPortraitToTexture to crop the imageAssuming that you’ve already created the BagBuddy frame using Luapreviously, you could create this texture like this:BagBuddy.portrait = BagBuddy:CreateTexture(“BagBuddy_Portrait“, i“BACKGROUND“)BagBuddy.portrait:SetWidth(60)BagBuddy.portrait:SetHeight(60)BagBuddy:SetPoint(“TOPLEFT“, 7, -6)Because each texture <strong>and</strong> font string need to belong to a parent, there issimply a method you call on the frame itself to create a new texture. The firstargument to CreateTexture is the name <strong>of</strong> the new texture <strong>and</strong> the second isthe layer on which to place the texture. There is a third argument that youlearn more about in Chapter 10.If you then wanted to set a graphics file to be loaded, you could accomplishthis with the SetTexture method:BagBuddy.portrait:SetTexture(“Interface\\Icons\\INV_Misc_EngGizmos_30“)Indeed, you can specify a solid color using the same method; <strong>for</strong> example,the following code sets the texture to be solid blue with 50% transparency:BagBuddy.portrait:SetTexture(0.0, 0.0, 1.0, 0.5)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!