Problems with canvas.popDialog
by Aubrey Youngs · in Torque Game Builder · 07/06/2008 (2:10 pm) · 2 replies
I'm fairly inexperienced with TGB, but I have been trying to write a bit of an adventure game. Right now, I can get my player to trigger a shop menu gui or a dialog gui (I nhaven't written those gui's yet, just have the place holders).
I currently have the gui's triggered by a collision with the appropriate person (I know, not the greatest, but it was the best way that I know how to do it right now) The correct gui displays on the screen, but when i try to make it go away and return to the level, it never does.
my console file doesn't say anything about incorrect scripting and there is nothing about the pop.Dialog.
This is the code for one of the GUIs I am havign problems with.
function TutorialQuestGiver::onCollision(%srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts)
{
if (%dstObj.class $= "humanPlayer")
{
//this should open the tutorial quest dialog.
canvas.pushDialog(TutorialQuest);
}
}
.....
new GuiBitmapButtonCtrl() {
canSaveDynamicFields = "0";
isContainer = "0";
Profile = "ExampleButtonProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = "416 347";
Extent = "140 30";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "canvas.popDialog(TutorialQuest);";
hovertime = "1000";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
};
};
Anyone have any suggestions?
I have the same problem with another one.
Thanks.
I currently have the gui's triggered by a collision with the appropriate person (I know, not the greatest, but it was the best way that I know how to do it right now) The correct gui displays on the screen, but when i try to make it go away and return to the level, it never does.
my console file doesn't say anything about incorrect scripting and there is nothing about the pop.Dialog.
This is the code for one of the GUIs I am havign problems with.
function TutorialQuestGiver::onCollision(%srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts)
{
if (%dstObj.class $= "humanPlayer")
{
//this should open the tutorial quest dialog.
canvas.pushDialog(TutorialQuest);
}
}
.....
new GuiBitmapButtonCtrl() {
canSaveDynamicFields = "0";
isContainer = "0";
Profile = "ExampleButtonProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = "416 347";
Extent = "140 30";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "canvas.popDialog(TutorialQuest);";
hovertime = "1000";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
};
};
Anyone have any suggestions?
I have the same problem with another one.
Thanks.
About the author
#2
07/09/2008 (10:23 am)
I didn't think of the trigger objects. I'm having a hard time finding tutorials on how to do some of this stuff. That's why I am loving the boards. Thanks for the advice. I will see what I can come up with.
Associate James Ford
Sickhead Games
Canvas.pushDialog(TutorialQuest);
to...
if ( Canvas.getContent() != TutorialQuest.getId() )
{
Canvas.pushDialog(TutorialQuest);
}
Actually, you should use collisions with a trigger object to open/close the gui because trigger objects have an onEnter and an onExit callback. That way you can only open the gui once onEnter and only close it once onExit (Or whatever the real callback is named).