setLinearVelocityX on Gui Elements
by Aditya Kulkarni · in Torque Game Builder · 02/04/2010 (6:26 am) · 6 replies
Is there any way I can do that without using guiT2DObjectCtrl or schedules?
#2
I first do this
'createDialogueObj' creates a new static sprite, attaches it to the gui object 'mainDialogueHud' and sets the X velocity as 50
Problem is that Canvas.popDialog doesn't work, not even from the console. I did dialogue.isAwake() and it returned a '0', but the gui is still being shown on the screen.
02/05/2010 (3:39 am)
Problemo...I first do this
Canvas.pushDialog(dialogue); createDialogueObj();
'createDialogueObj' creates a new static sprite, attaches it to the gui object 'mainDialogueHud' and sets the X velocity as 50
function createDialogueObj() {
$dialogueObj = new t2dStaticSprite() {
imageMap = "image1ImageMap";
frame = "0";
canSaveDynamicFields = "1";
Position = "-114 0";
size = "6 11";
layer = "0";
mountID = "3";
class = dialogueObj;
};
$sceneGraph = sceneWindow2D.getSceneGraph();
$sceneGraph.addToScene($dialogueObj);
$dialogueObj.attachGui(mainDialogueHud,sceneWindow2D,false);
$dialogueObj.setPositionTarget("-7 0", true, true, false, 0.01);
$dialogueObj.setLinearVelocityX(50);
}
function dialogueObj::onPositionTarget(%this) {
error ("TARGET POSITION REACHED!");
%this.setLinearVelocity(0,0);
$dialogueObj.detachGui();
}
function dialogueMouseArea::onMouseDown() {
echo ("DIALOGUE MOUSE AREA CLICKED!");
$dialogueObj.detachGui();
$dialogueObj.safeDelete();
Canvas.popDialog(dialogue);
}Problem is that Canvas.popDialog doesn't work, not even from the console. I did dialogue.isAwake() and it returned a '0', but the gui is still being shown on the screen.
#3
dialogue.isAwake() returns 0 AFTER calling Canvas.popDialog(dialogue), but the gui actually remains on screen.
02/05/2010 (3:48 am)
Tried it again. dialogue.isAwake() returns 0 AFTER calling Canvas.popDialog(dialogue), but the gui actually remains on screen.
#4
1) You attach "mainDialogueHud" to the sprite but try to remove just "dialogue".
2) I think that when you attach, it gets owned by the scene window. You might try "sceneWindow2D.remove(mainDialogueHud);". That should be enough, but it may not hurt to do a "mainDialogueHud.setVisible(false);".
02/05/2010 (6:36 am)
It looks like there might be 2 things going on here:1) You attach "mainDialogueHud" to the sprite but try to remove just "dialogue".
2) I think that when you attach, it gets owned by the scene window. You might try "sceneWindow2D.remove(mainDialogueHud);". That should be enough, but it may not hurt to do a "mainDialogueHud.setVisible(false);".
#5
sceneWindow2D.remove works like a charm. I was doing $dialogueObj.detachGui() before popDialog, so shouldn't that remove it from the scenewindow?
William strikes again...Thanks man!
02/05/2010 (7:00 am)
'mainDialogueHud' is a child to 'dialogue', so I thought removing dialogue would do it.sceneWindow2D.remove works like a charm. I was doing $dialogueObj.detachGui() before popDialog, so shouldn't that remove it from the scenewindow?
William strikes again...Thanks man!
#6
Anyway! Glad it all worked!
02/05/2010 (4:17 pm)
DetachGui is just detaching it from the scene object, but still leaves it as a child of the scene window.Anyway! Glad it all worked!
Associate William Lee Sims
Machine Code Games
The first requires a source license, so you'll probably want the second.