Game Development Community

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

#1
02/17/2008 (10:45 pm)
The Torsion IDE has great debugging support. You can set breakpoints and step through the code as needed.
#2
02/18/2008 (3:40 am)
Thanks Charles but how do I get to it? Also I'm on a Mac.

Joe B
#3
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