Problem using GameConnection::setBlackOut
by Bullitt Sesariza · in Torque Game Engine · 05/27/2008 (12:06 am) · 3 replies
Hi, in my game if the player dies, the screen will turn into a blackout until the game disconnected. I've tried this code:
The code is called from the "GameConnection::onDeath()" like this:
If I called the loseCmd directly from the console, it would go just like I wanted. The screen would turn to black gradually with the "You Lose!!!" bitmap displayed on top of it. But if I just kill the player (and thus the game calls GameConnection::onDeath), it would go from blackout and then it would display the screen again. So I was thinking that there is something that canceled the blackout in between the onDeath - disconnect.
cont...
function loseCmd()
{
ServerConnection.setBlackOut(true,2000); //Blackout!!!!!1
LoseMsg.visible = 1; //"You Lose!!!" message visible
Canvas.pushDialog("LoseDlg"); //Push the "You Lose!!!" message dialog so the message wouldn't be in the blackout
$Game::CurrentLife = 0; //So that the next level won't be loaded
schedule(5000, 0, disconnect); //Schedule Game Disconnect
//Check for timer alarm schedule
if (isObject($timerAlarmSched))
cancel($timerAlarmSched);
//Stop the 10 seconds left alarm SFX
if (alxIsPlaying($alarmSFX))
alxStop($alarmSFX);
}The code is called from the "GameConnection::onDeath()" like this:
function GameConnection::onDeath(%this, %sourceObject, %sourceClient, %damageType, %damLoc)
{
$Game::CurrentLife--;
setCurrentLife($Game::CurrentLife);
if($Game::CurrentLife>0)
{
%this.schedule($CorpseTimeoutValue, "respawn"); //Respawn Again
$Game::EnableControl = 0; //Disable controls
}
else
{
[b]loseCmd(); //Call lose cmd[/b]
}
}If I called the loseCmd directly from the console, it would go just like I wanted. The screen would turn to black gradually with the "You Lose!!!" bitmap displayed on top of it. But if I just kill the player (and thus the game calls GameConnection::onDeath), it would go from blackout and then it would display the screen again. So I was thinking that there is something that canceled the blackout in between the onDeath - disconnect.
cont...
#2
It's weird that the connection used the player / controlling object as a reference of the camera whether or not the current camera is attached to it (I used the Advanced Camera's static camera BTW so IMHO whether or not there's a player in the scene shouldn't matter). Now I have to change the code so that it won't delete the player and recreate it, but just disable the fade and reposition the player to the spawning transform instead. BTW, how do I unfade a shapeBase?
05/27/2008 (12:30 am)
Nevermind. It looks like it happened because this (in PlayerData::onDisabled()):%obj.schedule($CorpseTimeoutValue - 500, "startFade", 500, 0, true); %obj.schedule($CorpseTimeoutValue, "delete");
It's weird that the connection used the player / controlling object as a reference of the camera whether or not the current camera is attached to it (I used the Advanced Camera's static camera BTW so IMHO whether or not there's a player in the scene shouldn't matter). Now I have to change the code so that it won't delete the player and recreate it, but just disable the fade and reposition the player to the spawning transform instead. BTW, how do I unfade a shapeBase?
#3
05/27/2008 (12:44 am)
Nevermind again. It's been solved. Thanks for reading though. :D
Torque Owner Bullitt Sesariza
---------------------------------------- LoseCmd called from GameConnection::onDeath(): -------------------- Start LoseCmd Console trace is on. Entering [CanvasCursor]GuiCanvas::pushDialog(Canvas, LoseDlg) Entering LoseMsg::onWake(1247) Leaving LoseMsg::onWake() - return 1 Entering [CanvasCursor]GuiCanvas::checkCursor(Canvas) Leaving [CanvasCursor]GuiCanvas::checkCursor() - return 1246 Leaving [CanvasCursor]GuiCanvas::pushDialog() - return 1246 Leaving loseCmd() - return 0 Leaving GameConnection::onDeath() - return 0 Leaving PlayerBody::Damage() - return 0 Leaving ShapeBase::Damage() - return 0 Entering setFrogHead(2) Leaving setFrogHead() - return Leaving toggleDeath() - return 12 Entering updateConsoleErrorWindow() Leaving updateConsoleErrorWindow() - return Leaving ConsoleEntry::eval() - return Entering schedFrogIdle() Leaving schedFrogIdle() - return 62 Entering ToggleConsole(1) keyboard0 input device acquired. Entering [CanvasCursor]GuiCanvas::popDialog(Canvas, ConsoleDlg) Entering ConsoleDlg::onSleep() Leaving ConsoleDlg::onSleep() - return 500 300 Entering [CanvasCursor]GuiCanvas::checkCursor(Canvas) Leaving [CanvasCursor]GuiCanvas::checkCursor() - return 1246 Leaving [CanvasCursor]GuiCanvas::popDialog() - return 1246 Leaving ToggleConsole() - return 1246 Entering ToggleConsole(0) Leaving ToggleConsole() - return 0 Entering PlayerBody::onRemove(385, 2249) Leaving PlayerBody::onRemove() - return 0 Entering LowerBoundTrigger::onLeaveTrigger(35, 1695, 2249) Leaving LowerBoundTrigger::onLeaveTrigger() - return Entering Cam_0_Trigger::onLeaveTrigger(27, 1689, 2249) Leaving Cam_0_Trigger::onLeaveTrigger() - return Entering disconnect() -------------------- End LoseCmd ------------------------------------------------- Calling loseCmd directly: -------------------- Start LoseCmd Console trace is on. Entering [CanvasCursor]GuiCanvas::pushDialog(Canvas, LoseDlg) Entering LoseMsg::onWake(1247) Leaving LoseMsg::onWake() - return 1 Entering [CanvasCursor]GuiCanvas::checkCursor(Canvas) Leaving [CanvasCursor]GuiCanvas::checkCursor() - return 1246 Leaving [CanvasCursor]GuiCanvas::pushDialog() - return 1246 Leaving loseCmd() - return 0 Entering updateConsoleErrorWindow() Leaving updateConsoleErrorWindow() - return Leaving ConsoleEntry::eval() - return Entering ToggleConsole(1) keyboard0 input device acquired. Entering [CanvasCursor]GuiCanvas::popDialog(Canvas, ConsoleDlg) Entering ConsoleDlg::onSleep() Leaving ConsoleDlg::onSleep() - return 500 300 Entering [CanvasCursor]GuiCanvas::checkCursor(Canvas) Leaving [CanvasCursor]GuiCanvas::checkCursor() - return 1246 Leaving [CanvasCursor]GuiCanvas::popDialog() - return 1246 Leaving ToggleConsole() - return 1246 Entering ToggleConsole(0) Leaving ToggleConsole() - return 0 Entering schedFrogIdle() Leaving schedFrogIdle() - return 45 Entering disconnect() -------------------- End LoseCmdCan anybody help me here? I've been desperately trying to solve this in vain. Thanks in advance.