Game Development Community

Client side radar too

by John Coyne · in Torque Game Engine · 08/11/2005 (2:59 pm) · 2 replies

Didnt want to hijack the other post so here i go. I to have added the radar resource (thanks!), but want to expand it so the player can turn the radar on and off. So far i have this:


in GuiRadarCtrl.h

class GuiRadarCtrl : public GuiBitmapCtrl
{
private:
bool status;


public:
void onSwitch();
};

.......................................
in GuiRadarCtrl.cc

GuiRadarCtrl::GuiRadarCtrl(void)
{
status = true;
}

void GuiRadarCtrl::onSwitch()
{
printf("\nYou called the radar switch");
if (status)
{
status = false;
}
else
{
status = true;
}
}


void GuiRadarCtrl::onRender(Point2I offset, const RectI &updateRect)
{

.
(extra code removed)
.

//check the radar is on
if(status)
{
// Go through all ghosted objects on connection (client-side)

.
(extra code removed)
.


}//end if status;
}

// Draw static radar bitmap
if (mTextureHandle)
{

(extra code removed)


}//end on render



ConsoleMethod( GuiRadarCtrl, toggleRadarState, void, 1, 1, "toggleRadar()")
{
object->onSwitch();
}

.............................................

Then in default.bind.cs


function toggleRadar()
{
echo("Switching radar");
PlayerRadar->toggleRadarState();
}
moveMap.bind(keyboard, o, toggleRadar );

................................................



Pressing "o" or any other key i bind the command to doesnt even print my echo. and typeing "playerRadar.toggleRadarState();" at the console gives me a "wrong number of arguments error".
Typeing "toggleRadar();" prints the echo and tells me "unknown command onSwitch.".

Anyone got any ideas?

#1
08/12/2005 (5:57 am)
Try changing

function toggleRadar()
{
  echo("Switching radar");
  PlayerRadar->toggleRadarState();
}

to

function toggleRadar(%val)
{
  echo("Switching radar");
  PlayerRadar->toggleRadarState();
}

Where val will be 1 or 0 depending on whether the key was pressed or released.

Also change your min/max args from 1 to 2 in the consoleMethod.
#2
08/12/2005 (4:50 pm)
Thanks, i'll give that a go