OnWake/OnSleep functions not working...[RESOLVED]
by Orion the Hunter · in Torque Game Builder · 12/07/2012 (8:33 pm) · 4 replies
Guess who,
I was wondering how to get the onWake and onSleep functions to work. The console gives me no errors whatsoever to work with. Also, I know that such a function exists after referring to several other pre-made scripts (that I didn't make). I'm probably just writing the code wrong. So I have this loading gui and I'm trying to make it so that when it's woken up it will load the level. Here it is:
None of the echo functions come up...
Thanks!
I was wondering how to get the onWake and onSleep functions to work. The console gives me no errors whatsoever to work with. Also, I know that such a function exists after referring to several other pre-made scripts (that I didn't make). I'm probably just writing the code wrong. So I have this loading gui and I'm trying to make it so that when it's woken up it will load the level. Here it is:
//--- OBJECT WRITE BEGIN ---
%guiContent = new GuiBitmapCtrl(NowLoadingGui) {
canSaveDynamicFields = "0";
isContainer = "1";
Profile = "GuiDefaultProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = "0 0";
Extent = "1024 768";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
bitmap = "~/data/images/nowloading.png";
wrap = "0";
};
function NowLoadingGui::onWake()
{
_newGame();
readFile();
echo("Loading...");
}
function NowLoadingGui::onSleep()
{
echo("Done.");
}
//--- OBJECT WRITE END ---None of the echo functions come up...
Thanks!
#2
12/08/2012 (5:49 am)
What? You need to push it?
#3
12/08/2012 (7:50 am)
If you never show a gui it never wakes. The way to show a gui is to push it to a canvas or create a new instance of it and add it to an existing gui object. So yes.// displays a fullscreen gui (or a non-fullscreen gui will be displayed fullscreen). // onWake() will be called. Canvas.pushDialog(MyGui); // removes the gui. onSleep() will be called. Canvas.popDialog(MyGui); // adds a gui to another. onWake() will be called. MyCurrentGui.add(MyGui); // removed a gui object from another. onSleep() will be called. MyCurrentGui.remove(MyGui);
#4
12/08/2012 (9:41 am)
I usually use "set content" but I guess that's not the same... Thanks, I got it working now! :)
Torque Owner Richard Ranft
Roostertail Games