Create sprites in GUI screens (not inside the game level)
by Fernando Sansberro · in Torque Game Builder · 11/22/2006 (12:14 pm) · 9 replies
Hi,
I am trying to spawn a sprite but this code is in the context of a gui screen (the game level is ended here).
The code comes aftear a Canvas.pushDialog (xxxx) sentence:
$plane = new t2dStaticSprite()
{
sceneGraph = ????????????;
class = "plane";
layer = 1;
imageMap = "avionsitoImageMap";
size = $PLANE_WIDTH SPC $PLANE_HEIGHT;
frame = 0;
};
$plane.setPosition(0, 0);
Is this possible? The sprite does not appear on the screen. I tried with a lot of things in place of ?????.
Thanks.
Regards,
Fernando.
I am trying to spawn a sprite but this code is in the context of a gui screen (the game level is ended here).
The code comes aftear a Canvas.pushDialog (xxxx) sentence:
$plane = new t2dStaticSprite()
{
sceneGraph = ????????????;
class = "plane";
layer = 1;
imageMap = "avionsitoImageMap";
size = $PLANE_WIDTH SPC $PLANE_HEIGHT;
frame = 0;
};
$plane.setPosition(0, 0);
Is this possible? The sprite does not appear on the screen. I tried with a lot of things in place of ?????.
Thanks.
Regards,
Fernando.
About the author
#2
11/24/2006 (8:27 am)
Have you tried building two guis, and push the one with the scenewindow to a higher gui layer?
#3
What I am doing now it ehat says in this article.
http://tdn.garagegames.com/wiki/Torque_2D/StandardTutorials/Basics/GuiScene
In this article the author creates a t2dSceneWindow control in the gui and then he creates the sprite setting the scenegraph to that control.
The problem now is that if I want to move the sprite all over the screen, the control is limited and if I make the control bigger the sprite also scale, and the gui controls below the sprite ara unresponsiveness, etc. etc...
This is quite frustrating. I only need to move a sprite on top of a gui, nothing more simple than that!
Thanks.
Regards,
Fernando.
11/24/2006 (9:19 am)
Yes, this will work also I suppose. What I am doing now it ehat says in this article.
http://tdn.garagegames.com/wiki/Torque_2D/StandardTutorials/Basics/GuiScene
In this article the author creates a t2dSceneWindow control in the gui and then he creates the sprite setting the scenegraph to that control.
The problem now is that if I want to move the sprite all over the screen, the control is limited and if I make the control bigger the sprite also scale, and the gui controls below the sprite ara unresponsiveness, etc. etc...
This is quite frustrating. I only need to move a sprite on top of a gui, nothing more simple than that!
Thanks.
Regards,
Fernando.
#4
Have a look at the animation editor GUI and some of the other level builder GUIs - they all use scene graphs in side the GUI controls.
e.g. check: games/tools/animationEditor/gui/AnimationEditorGUI.ed.gui as well as the scripts.
Just remember that the scene window will capture input so make sure you set the first responder stuff correctly, etc.
02/10/2007 (9:59 am)
I would not use a separate t2dSceneWindow for each sprite, just use one t2dSceneWindow that covers the whole gui and add it to the correct parent control so it is above whatever it needs to be.Have a look at the animation editor GUI and some of the other level builder GUIs - they all use scene graphs in side the GUI controls.
e.g. check: games/tools/animationEditor/gui/AnimationEditorGUI.ed.gui as well as the scripts.
Just remember that the scene window will capture input so make sure you set the first responder stuff correctly, etc.
#5
Anyone have a solution to that?
02/11/2007 (6:39 am)
I've tried doing this before as well in a way, but I wanted to move particles around on top of the GUI. I haven't really found a solution yet since if you put stuff on top of your UI buttons and what not you lose the ability to interact with your GUI.Anyone have a solution to that?
#6
02/11/2007 (9:58 am)
Does playing around with the first responder settings not fix it?
#7
02/11/2007 (10:55 am)
Maybe, I'll try it. I already tried but I probably didn't try hard enough. Maybe that's it.
#8
If there is something I am missing here I would much appreciate someone letting me know what it is because it would be really nice to be able to put effects and what not on top of my GUI when needed. I've tried searching but I get a bunch of posts I can't access and a bunch of other unrelated things.
Thanks :)
02/12/2007 (3:33 am)
Yeah I've been playing around with putting a t2dscenewindow on top of buttons and trying to press the buttons. I've gone into the .gui file and added "willFirstRespond = "0";" to the t2dscenewindows attribs, that does nothing. I've tried using setfirstresponder(); on both the t2dscenewindow and the button, doesn't work. I've tried using makefirstresponder(true); on both as well and it doesn't work.If there is something I am missing here I would much appreciate someone letting me know what it is because it would be really nice to be able to put effects and what not on top of my GUI when needed. I've tried searching but I get a bunch of posts I can't access and a bunch of other unrelated things.
Thanks :)
#9
02/12/2007 (4:30 am)
Oh and makefirstresponder(false); too of course :P
Torque Owner Fernando Sansberro
Now I do not end the level when I push the dialog (it is a transitional screen between levels), in order to have a t2dScene. The sprite now appears but it appears behind the gui dialog.
The question now is, how can I spawn sprites to appear in front of the gui dialog ?
Thanks.
Regards,
Fernando.