setBlend() for GUI elements?
by Adam Albee · in Torque Game Builder · 10/04/2011 (11:19 am) · 7 replies
Is there anything similar to setBlend() for GUI elements? Basically just trying to do a color coded damage indicator, more damage = more red. Easy enough to to with scene objects, but couldn't find anything similar for GUI elements.
About the author
#2
The only immediate downside is that t2dtextobjects are finicky. Make sure to use a font with a pixel or two of extra space between characters, because it has trouble splitting the characters when rendering and you end up with annoying vertical lines in your text.
10/27/2011 (11:17 am)
Ah how I love SOGUIs. The other neat thing with that approach is that you can construct different GUI screens as their own level, and then load them directly into GUIWindow2D. Makes things much more organized!The only immediate downside is that t2dtextobjects are finicky. Make sure to use a font with a pixel or two of extra space between characters, because it has trouble splitting the characters when rendering and you end up with annoying vertical lines in your text.
#3
#1: Resizing. Guess this doesn't matter too much, but one nice thing about using the GUI system was the ability to have elements move rather than simply stretch out during resolution changes. Is there an easy way to handle this using this system. I have an idea for how I would go about doing it otherwise, but figured there might be something relatively simple to try first.
#2: Mouse events. This is the major issue. I have the Gui scene set as William suggested above, which is all good, but I still need mouse events to be handled on the sceneWindow2D level. Things like clicking on world objects and enemies. Am I missing something simple here to make that work?
Again, thank you both!
12/20/2011 (7:19 pm)
First off, thank you both for helping out here, I'm a little late with that. Anyhow, I had figured something out for that little project before seeing your posts. Then, I sorta just forgot about this for a while until recently I started working on some things. So, I dug this out to give it a whirl. Couple of issues that popped up right away.#1: Resizing. Guess this doesn't matter too much, but one nice thing about using the GUI system was the ability to have elements move rather than simply stretch out during resolution changes. Is there an easy way to handle this using this system. I have an idea for how I would go about doing it otherwise, but figured there might be something relatively simple to try first.
#2: Mouse events. This is the major issue. I have the Gui scene set as William suggested above, which is all good, but I still need mouse events to be handled on the sceneWindow2D level. Things like clicking on world objects and enemies. Am I missing something simple here to make that work?
Again, thank you both!
#4
As for resizing, there's no automatic way to have it place extra space on a single side (positioning relative to an edge). You'd have to write custom code to handle that.
12/20/2011 (8:12 pm)
If you check out www.garagegames.com/community/forums/viewthread/109707, I have instructions for modifying the engine to let events pass through if they weren't picked up by the top-level scene window. The steps are in comments #4 and #13.As for resizing, there's no automatic way to have it place extra space on a single side (positioning relative to an edge). You'd have to write custom code to handle that.
#5
12/20/2011 (8:18 pm)
Wow, that was fast! Thanks William, I think that's exactly what I needed. I figured as much for the repositioning, just thought I'd ask in case there was something easy, heh. Anyhow, time for bed now, but I'll be giving that a shot in the morning. Thanks again!
#6
12/21/2011 (12:17 pm)
Alright, it worked perfectly. It is awesome, you're awesome William, and now I'm ready to enter the exciting world of SOGUIs! Also, at first I was discouraged by the "test of skill" you had placed upon your code since I hadn't dug deep into C++ for a while, but turns out I can still work my way through it, so thanks for forcing me to exercise skills I haven't used in a while!
#7
12/21/2011 (12:21 pm)
You're welcome! Let me know if you run into any problems setting up the scene. (P.S. I definitely recommend using collision polygons on GUI elements if they have a non-rectangular shape.)
Associate William Lee Sims
Machine Code Games
If it's text (for example), then you can change the profile through TorqueScript:
But most things cannot be changed in this manner.
If your GUI is mostly graphics, you can build another scene on top of your current one to build a GUI. In that case, you'll be able to use all of T2D's capabilities for blending. I often have the following in mainScreen.gui:
//--- OBJECT WRITE BEGIN --- %guiContent = new GuiControl(mainScreenGui) { canSaveDynamicFields = "0"; Profile = "GuiBlackContentProfile"; HorizSizing = "width"; VertSizing = "height"; Position = "0 0"; Extent = "1024 768"; MinExtent = "8 8"; canSave = "1"; Visible = "1"; useVariable = "0"; new t2dSceneWindow(sceneWindow2D) { canSaveDynamicFields = "0"; Profile = "GuiContentProfile"; HorizSizing = "width"; VertSizing = "height"; Position = "0 0"; Extent = "1024 768"; MinExtent = "8 8"; canSave = "1"; Visible = "1"; lockMouse = "0"; useWindowMouseEvents = "1"; useObjectMouseEvents = "1"; }; new t2dSceneWindow(guiWindow2D) { canSaveDynamicFields = "0"; Profile = "GuiContentProfile"; HorizSizing = "width"; VertSizing = "height"; Position = "0 0"; Extent = "1024 768"; MinExtent = "8 8"; canSave = "1"; Visible = "1"; lockMouse = "0"; useWindowMouseEvents = "1"; useObjectMouseEvents = "1"; }; }; //--- OBJECT WRITE END ---I load the game into "sceneWindow2D" and my GUI into "guiWindow2D".