Mouse Input/Callbacks
by Steven Meek · in Torque Game Builder · 12/05/2007 (8:48 pm) · 5 replies
I have a game, I'm trying to get a response from the mouse movement. Essentially its a simple TD type game, so I need to be able to create a tower by clicking on the GUI bitmap button then have the t2dstaticsprite follow the mouse until the user clicks somewhere on the level with it.
Why can I only receive mouse callbacks when the GUI isn't there.... How do I work around this?
Why can I only receive mouse callbacks when the GUI isn't there.... How do I work around this?
About the author
#2
Thank you in advance for any assistance you can offer!
marcus
12/15/2007 (10:34 am)
Hi Steven and Simon, I'm trying to do the same thing. Have the player be able to click on an object/sprite and drop it on something else (this is a very basic kids game for a friend), and I was wondering if either of you would have a more complete example that you would be willing to share. Basically I have a couple of scenes, with a few sprites that the player should be able to click on once to "pick up", have it follow the mouse to the new location, and click again to drop it (I still need to detect that it was dropped). This is for a 4-year old, so I'm trying to keep the actions/moves simple.Thank you in advance for any assistance you can offer!
marcus
#3
Try taking a look at the Checkers Tutorial, It should get you started with picking up and dropping items.
Part 5 of the tutorial is all about picking up the checkers.
12/15/2007 (10:47 am)
Hi Marcus.Try taking a look at the Checkers Tutorial, It should get you started with picking up and dropping items.
Part 5 of the tutorial is all about picking up the checkers.
#4
Well you could do a follow mouse behaviour and then when you click, it gets the x and y coordinates. Then it creates the static shape/animation at the position it held earlier.
12/15/2007 (3:48 pm)
Wow, 3 posts that say the same thing!Well you could do a follow mouse behaviour and then when you click, it gets the x and y coordinates. Then it creates the static shape/animation at the position it held earlier.
#5
Marcus
12/17/2007 (2:37 pm)
Thanks guys, I got it working now. Got both my level loads and my object pickup working. Appreciate the help!Marcus
Torque 3D Owner Simon Jensen
SwiftThought Games
I'm using something like :
new GuiControlProfile(MyNewTransparentProfile) { modal = false; border = false; };I saved that in game/gameScripts/customGuiProfiles.csWhich lets my mouse callbacks 'go through' the GUI Except when I mouse over gui elements that dont have that profile.
So in my datablocks.cs i added
// load Custom Gui Profiles exec("game/gameScripts/customGuiProfiles.cs");which lets me use the GUI editor and have it see my custom profiles.and then my actual gui file looks something like
//--- OBJECT WRITE BEGIN --- %guiContent = new GuiControl(cellCountGui) { canSaveDynamicFields = "0"; isContainer = "1"; Profile = "MyNewTransparentProfile"; HorizSizing = "right"; VertSizing = "bottom"; Position = "0 0"; Extent = "640 480"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; hovertime = "1000"; new GuiTextCtrl() {.... ..... more controls etc etc .... }; };Not entirely sure why this works but It seems to work. Unfortunately the GUI documentation is scattered all over the place and not too terribly useful so I haven't been able to find a definitive answer.
Hope this helps.