Displaying a pop-up window on top of the scene window???
by Teddy Setiawan Wijaya · in Torque Game Builder · 10/04/2006 (3:35 am) · 4 replies
Hi All,
In the demo that I am currently developing, what I want to do is:
1. When the player approaches the door, there will be an arrow displayed above the door indicating that the player can interact with the door
2. If after the arrow is displayed, the player presses SPACE, a dialog box will pop up at the center of the screen, asking the player whether he/she wants to leave the house (with the Yes and No button)
1 => no problem, thanks to castCollision and the amazing community of TGB..;-)
2 => well, this is why I posted this thread
What I did was
1. Open the GUI builder then pick the MainScreenGui
2. Create GuiControl under MainScreenGui and place it at the center then define its size
3. Create GuiWindowCtrl under (as a child of) GuiControl
4. Place GuiTextCtrl and two GuiButtonCtrl under (as children of) the GuiWindowCtrl
5. In the command field of the "No" ButtonCtrl, I call function closeDlgWindow
6. Bind the space button to a new function (doAction) to handle player pressing SPACE button.
7. Add the code for doAction and closeDlgWindow
At first, in my doAction I used the following code
note: portalGui is the name of my GuiControl
the code for function closeDlgWindow (called when player presses the button "No")
The code above works fine but the dialog box is always displayed at the top left of the screen (0,0). Why doesn't the setPosition do anything?
then I rewrote the code by commenting out the pushDialog and popDialog thing, so now I only use the setVisible method. The result: it works as expected (dialog box displayed at screen center, when button "No" is pressed, the dialog box will be disappear)
My questions are:
1. Does popDialog and pushDialog always display the new window at position 0,0 ? (Regardless of the setPosition method called afterward)
2. What are the differences between the two ways of displaying the dialog box above (using pushDialog and without using pushDialog)? Is there any effect on memory usage?
3. Is there a better way (in terms of memory usage) to display the dialog box? (like for example: by creating the dialog box on the fly, without putting it on mainscreenGui)
Sorry for the long posting (I am a newbie)
Many thanks,
In the demo that I am currently developing, what I want to do is:
1. When the player approaches the door, there will be an arrow displayed above the door indicating that the player can interact with the door
2. If after the arrow is displayed, the player presses SPACE, a dialog box will pop up at the center of the screen, asking the player whether he/she wants to leave the house (with the Yes and No button)
1 => no problem, thanks to castCollision and the amazing community of TGB..;-)
2 => well, this is why I posted this thread
What I did was
1. Open the GUI builder then pick the MainScreenGui
2. Create GuiControl under MainScreenGui and place it at the center then define its size
3. Create GuiWindowCtrl under (as a child of) GuiControl
4. Place GuiTextCtrl and two GuiButtonCtrl under (as children of) the GuiWindowCtrl
5. In the command field of the "No" ButtonCtrl, I call function closeDlgWindow
6. Bind the space button to a new function (doAction) to handle player pressing SPACE button.
7. Add the code for doAction and closeDlgWindow
At first, in my doAction I used the following code
note: portalGui is the name of my GuiControl
Canvas.pushDialog(portalGui); portalGui.setVisible(true); portalGui.setPosition(250, 189);
the code for function closeDlgWindow (called when player presses the button "No")
Canvas.popDialog(portalGui); portalGui.setVisible(false);
The code above works fine but the dialog box is always displayed at the top left of the screen (0,0). Why doesn't the setPosition do anything?
then I rewrote the code by commenting out the pushDialog and popDialog thing, so now I only use the setVisible method. The result: it works as expected (dialog box displayed at screen center, when button "No" is pressed, the dialog box will be disappear)
My questions are:
1. Does popDialog and pushDialog always display the new window at position 0,0 ? (Regardless of the setPosition method called afterward)
2. What are the differences between the two ways of displaying the dialog box above (using pushDialog and without using pushDialog)? Is there any effect on memory usage?
3. Is there a better way (in terms of memory usage) to display the dialog box? (like for example: by creating the dialog box on the fly, without putting it on mainscreenGui)
Sorry for the long posting (I am a newbie)
Many thanks,
#2
I have tried the following code
the portalGui is still displayed at the top left...;-(
10/05/2006 (3:25 am)
Teck Lee,I have tried the following code
Canvas.pushDialog(portalGui);
portalGui.setVisible(true);
portalGui.setPosition("250 189");the portalGui is still displayed at the top left...;-(
#3
10/05/2006 (8:20 am)
Make sure your portalGui contains a container gui that is the full size of the screen. Check this recent thread.
#4
Yes, it turns out that I defined the container in a wrong way... no wonder the setPosition doesn't work.
Cheers!
10/05/2006 (10:12 pm)
Ben, thank you for the info and for pointing out the thread.Yes, it turns out that I defined the container in a wrong way... no wonder the setPosition doesn't work.
Cheers!
Torque Owner Teck Lee Tan
You have:
This should be:
portalGui.setPosition("250 189");Note the subtle difference. For paired coordinates, Torquescript typically takes a paired set in the form of a string.