Game Development Community

Control GUI

by Scott Barlow · in iTorque 2D · 06/27/2009 (10:21 am) · 1 replies

Currently I have gone through the mini tutorials on the GUI but I have run into a problem that has made me question if I am on the right path or not. In the GUI I have found that I can do a command callback to the game.cs for the button push but I am unable to find how to have the button release trigger an event.

Let me try to explain what kind of GUI I am going after to see if someone can push me in the right direction. Currently I am having the camera mounted to the player object. I then want to have the player controls mounted to the scene/camera so that it follows the camera as well. The GUI would be a very simple GUI with an up button and a down button. I am looking for when the button is down for an action to take place (code already done for this action). Then when the button is released, or in the case of iTGB moved off of, the action is suspended (again, code already done for this action suspension). This would be the case for both buttons.

I have currently tried to have an image map work as a control. This works but once I mount the camera to the player the controls do not follow the camera. I have also tried to mount the player to a scene object that has the controls mounted to it as well, but I found that the rotation of the player gets all messed up when mounted and the movement of the player no longer functions. I also have tried the GUI Builder, which solves my following the camera around problem but I am unable to find a way to register the release, as previously explained.

I have been searching the forums for about a week trying to find out the best way to build a control set, specifically for iTGB, but have been unable to nail down what is best. I have found that a lot of what the search pulls up is older content that is prior to iTGB release and thus confuses me on what is relevant or not.

Can anyone help guide me in the proper direction?

Thank you for your time.

#1
06/30/2009 (10:31 am)
I think the command option only works as you have described, but GUI buttons should have an onClick() callback you can use instead for the same functionality.

The Script call "onClick()" is called from GuiButtonBaseCtrl::onAction() in GuiButtonBase::onMouseUp(), you could easily add a call to GuiButtonBase::onMouseDown() that would execute another script function to do what you want.