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 ---
//--- 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 ---
Torque Owner Doug Linley
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.