Calling functions
by Joe Banko · in Torque Game Builder · 02/17/2008 (10:20 pm) · 3 replies
I have created 4 sprites (enemy) with the same class ($eShip) and in a group that I have numbered 4. I would like to have them check for their x and y distance from another sprite (player/$pShip). I have two GuiTextCtrl fields on my main Gui screen attached to 2 variables $locX, $locY (for debugging). In my game.cs script I have:
$enemies = $eShip.getGraphGroup;
...
...
function t2dSceneGraph::onUpdateScene(%this)
{
for (%i = 0; %i < $enemies.getCount; %i++)
{
playerClose($enemies.getObject(%i));
}
$locY = "past enemy";
}
And in my enemy.cs I have:
function playerClose(%this)
{
$locX = "in enemy";
}
I originally had code in this function and finally tracked the issue down to playerClose never getting executed because my $locX never shows "in enemy" but $locY shows "past enemy".
2 Questions:
Why doesn't playerClose execute?
Is there a better way (breakpoint, stepping) to debug code that using onscreen text fields? The console, but how do I get to it?
Thanks,
JB
$enemies = $eShip.getGraphGroup;
...
...
function t2dSceneGraph::onUpdateScene(%this)
{
for (%i = 0; %i < $enemies.getCount; %i++)
{
playerClose($enemies.getObject(%i));
}
$locY = "past enemy";
}
And in my enemy.cs I have:
function playerClose(%this)
{
$locX = "in enemy";
}
I originally had code in this function and finally tracked the issue down to playerClose never getting executed because my $locX never shows "in enemy" but $locY shows "past enemy".
2 Questions:
Why doesn't playerClose execute?
Is there a better way (breakpoint, stepping) to debug code that using onscreen text fields? The console, but how do I get to it?
Thanks,
JB
About the author
#3
Progress, what a wonderful feeling......
Thanks,
Joe B
02/18/2008 (8:41 am)
AH, Windows only (no surprise there). But in rooting around on the forum I did find out how to get into the console which has provided me with a general idea of what my issue was. It's not breakpoint/stepping but the messages do help. I guess my next stop is figuring out how to use groups (SimSet/SimObject?????) to handle multiple enemy sprites.Progress, what a wonderful feeling......
Thanks,
Joe B
Torque Owner Charles Freedman