Editor like mouse control on gameTSCtrl
by Adam Beer · in Torque 3D Professional · 02/01/2011 (9:47 am) · 5 replies
I am trying to get an RPG-like gameTSCtrl with the mouse displayed and when the right mouse is clicked and dragged, control is sent to the control object. I have looked at editTSCtrl and guiTSCrtl an have found nothing that points to how this is done. Currently im doing this (and it doesnt work too well):
Does anyone know of a better way to do this? One where the cursor disappears like in the editor when right-click-dragging?
void GameTSCtrl::onMouseDragged( const GuiEvent &evt)
{
static const char *argv[2];
Point2I diff( evt.mousePoint - mLastMousePos);
// Perform script-based yaw and pitch callbacks
if (diff.x) {
argv[0] = "yaw";
argv[1] = Con::getFloatArg( diff.x);
Con::execute( 2, argv);
}
if (diff.y) {
argv[0] = "pitch";
argv[1] = Con::getFloatArg( diff.y);
Con::execute( 2, argv);
}
}Does anyone know of a better way to do this? One where the cursor disappears like in the editor when right-click-dragging?
About the author
Adam is the owner of Ignition Games, an indie game and software development company.
#2
02/02/2011 (6:42 pm)
Try using Canvas.hideCursor() and Canvas.showCursor() instead of PlayGui.noCursor
#3
02/02/2011 (6:46 pm)
That does work but it doesnt enable/disable control, it just hides/unhides the actual cursor.
#4
02/02/2011 (7:29 pm)
I don't know if this is exactly what you want, but you could use hideCursor(). It completely disables controls from reacting to it.
#5
02/03/2011 (6:31 pm)
That unfortunately wont work, thanks for the suggestions though. Anyone else have any ideas? Ive seen this done in torque a few times before, I just cant find any resources. Anyone?
Torque Owner Adam Beer
Ignition Games Inc.
function GameTSCtrl::onRightMouseUp(%this, %pos, %start, %ray) { echo("onRightMouseUp"); PlayGui.noCursor = 0; } function GameTSCtrl::onRightMouseDown(%this, %pos, %start, %ray) { echo("onRightMouseDown"); PlayGui.noCursor = 1; }The callbacks work, but the cursor doesnt hide and unhide. When I put those exact commands in the console (PlayGui.noCursor) it works fine. Does anyone have any ideas?