Game Development Community

Calling client functions from a GUI

by Kevin James · in Torque Game Builder · 03/31/2005 (10:11 am) · 2 replies

I want the game to wait until "Start" is pressed in the GUI:

new GuiButtonCtrl()
{
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "580 0";
extent = "40 15";
minExtent = "8 2";
visible = "1";
text = "Start";
groupNum = "-1";
buttonType = "PushButton";
command = "setupT2DScene();";
};

I commented out the last line in initialiseClient where setupT2DScene is called, hoping that the GUI could do it with a button click. I'm lost as to why this doesn't work.

About the author

Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/


#1
03/31/2005 (10:20 am)
What I would do is just have all of your game code broken down, like the tutorial has you do and bring it all to one function

function startMyGame()
{
setupImages();
etc
etc
etc
}

then have the button call that
#2
03/31/2005 (10:33 am)
Omg.. that worked. I don't understand why it made a difference but it did...

I went from this:
function setupT2DScene()
{
new fxSceneGraph2D(t2dSceneGraph);
sceneWindow2D.setSceneGraph( t2dSceneGraph );
sceneWindow2D.setCurrentCameraPosition( "0 0 100 75" );

SetupImages();
CreatePlayer();
CreateTileMap();
}

To this:

function setupT2DScene()
{
new fxSceneGraph2D(t2dSceneGraph);
sceneWindow2D.setSceneGraph( t2dSceneGraph );
sceneWindow2D.setCurrentCameraPosition( "0 0 100 75" );
}

function StartupGame()
{
SetupImages();
CreatePlayer();
CreateTileMap();
}

put setupT2DScene back in initialiseClient and changed the GUI to this:
command = "StartupGame();";

ALL HAIL KING BOB!