SetText not updating text field
by Greg Squire · in Torque Game Builder · 01/16/2007 (7:00 pm) · 4 replies
I setup a simple HUD to display the score in my shooter game. It's using code based on the scrollerDemo project. It seems to use much the same code as this tutorial.
Here's my function (below) that updates the score (I am getting the echo stuff written to the console so I know that the function is being called. However the "currentScore" guiTextCtrl object never changes to reflect the new score. Any Ideas?
Here's my mainScreen.gui file
Here's my function (below) that updates the score (I am getting the echo stuff written to the console so I know that the function is being called. However the "currentScore" guiTextCtrl object never changes to reflect the new score. Any Ideas?
function updateScores(%points)
{
$score += %points;
//currentScore.setText(mFloor($score));
currentScore.setText($score);
echo("set score to " @ $score @ " (added " @ %points @ " points).");
}Here's my mainScreen.gui file
//--- OBJECT WRITE BEGIN ---
new GuiChunkedBitmapCtrl(mainScreenGui) {
canSaveDynamicFields = "0";
Profile = "GuiContentProfile";
HorizSizing = "width";
VertSizing = "height";
position = "0 0";
Extent = "800 600";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
hovertime = "1000";
useVariable = "0";
tile = "0";
new t2dSceneWindow(sceneWindow2D) {
canSaveDynamicFields = "0";
Profile = "GuiContentProfile";
HorizSizing = "width";
VertSizing = "height";
position = "1 -2";
Extent = "800 600";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
hovertime = "1000";
lockMouse = "0";
useWindowMouseEvents = "1";
useObjectMouseEvents = "0";
};
new GuiControl() {
canSaveDynamicFields = "0";
Profile = "GuiTransparentProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "20 13";
Extent = "763 38";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
new GuiTextCtrl() {
canSaveDynamicFields = "0";
Profile = "GuiText24Profile";
HorizSizing = "right";
VertSizing = "bottom";
position = "224 4";
Extent = "68 26";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
text = "Score:";
maxLength = "1024";
};
new GuiTextCtrl(currentScore) {
canSaveDynamicFields = "0";
Profile = "GuiText24Profile";
HorizSizing = "right";
VertSizing = "bottom";
position = "296 5";
Extent = "201 26";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
text = "0";
maxLength = "1024";
};
};
};
//--- OBJECT WRITE END ---
#2
01/16/2007 (8:34 pm)
I'm not looking for a text input object, just a text label to display the score. I thought that what the GuiTextCtrl object was. Am I wrong?
#3
01/16/2007 (9:15 pm)
You seem to be using it properly. Is your 0 showing up? If you move currentScore out of the grouping it is in, so that it appears under sceneWindow2D (not in it) does it update for you?
#4
I'm thinking the problem may have something to do with some modifications I did some time back to allow for the mouse to control the player. It's basically capturing the mouse events on the sceneWindow2D object. Maybe that's not the best way to do that. There are some other funky things happening (and maybe they are related), such as not getting the debug banner to come up either. I'm going to have to really dig on this one.
01/17/2007 (1:01 am)
The 0 is showing up, but it never changes. I haven't tried changing the grouping; I guess I could play with that some. I'm thinking the problem may have something to do with some modifications I did some time back to allow for the mouse to control the player. It's basically capturing the mouse events on the sceneWindow2D object. Maybe that's not the best way to do that. There are some other funky things happening (and maybe they are related), such as not getting the debug banner to come up either. I'm going to have to really dig on this one.
Torque Owner Drew -Gaiiden- Sikora