Game Development Community

Mouse click?

by Jeffrey T. Spicer · in Torque Game Builder · 07/03/2006 (9:28 pm) · 2 replies

I have a main screen that goes right into my game, but I want it to wait for a mouse click until it goes into the game. I've tried all the tutorials, but I can't get this to work. Here is my code: (the game is called "Host," thus the referencing to it in script):

//--- OBJECT WRITE BEGIN ---

function loadHostMainPage()
{
canvas.setContent(HostMainPage);
schedule(1000, 0, checkHostMainPage);
}

function checkHostMainPage()
{
// WHAT GOES HERE TO WAIT FOR A MOUSE CLICK?
startGame("HOST/data/levels/TheHostLevel.t2d");
}

new GuiBitmapCtrl(HostMainPage) {
canSaveDynamicFields = "0";
Profile = "GuiDefaultProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = "0 0";
Extent = "640 480";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
bitmap = "~/data/images/HostMainPage.png";
wrap = "0";
};
//--- OBJECT WRITE END ---

#1
07/04/2006 (5:43 pm)
Not sure it's the best way, but one way you could do it is to put the loading of the level in a function outside of start game. Then in start game you could call

sceneWindow2D.setUseObjectMouseEvents(true);


Then you need to set up the onMouseDown callback function

function sceneWindow2D::onMouseDown(%this, %modifiers, %worldPos, %mouseClicks)
{
    LoadHostGame("HOST/data/levels/TheHostLevel.t2d");
}

You could also set the mouse events flag to true in main and then call startGame from the onMouseDown callback.
#2
07/04/2006 (7:54 pm)
Thanks