%modifiers in onMouseDown for playGUI - do they work?
by Matthew Genge · in Torque 3D Professional · 06/18/2012 (4:11 pm) · 2 replies
I am trying to get an RTS camera working. I've managed to work around the lack of a working onMouseDragged using a schedule. I am now trying to make the camera turn if the shift button is pressed when the mouse is dragged. If there is any sense at all the code below should work...however...even when no button at all is pressed except the mouse button the value in %modifier changes every five or six clicks...and half of these return true with a bitwise comparison to $EventModifier::LSHIFT.
So my question is...it it broke...or have I made a mistake? I have added useModifiers="1" to playGUI, but it doesn't seem to make any difference.
Many thanks for any tips.
So my question is...it it broke...or have I made a mistake? I have added useModifiers="1" to playGUI, but it doesn't seem to make any difference.
function PlayGui::onMouseDown(%this, %modifier, %mousepos, %mouseclick)
{
//Save the cursor values
%mousepos = Canvas.getCursorPos();
LocalClientConnection.cursorX = getWord(%mousepos,0);
LocalClientConnection.cursorY = getWord(%mousepos,1);
LocalClientConnection.mouseisDown = 1;
echo(%modifier SPC (%modifier & $EventModifier::LSHIFT));
if(%modifier & $EventModifier::LSHIFT){
%this.schedule(50, "mouseTurnCamera");
} else {
%this.schedule(50, "mouseDragged");
}
}Many thanks for any tips.
About the author
I am an Earth Scientist who likes writing games for fun.
#2
Using a schedule actually works very well. I have a work around for the shift key, to simply bind it and set a clientside variable. So:
06/19/2012 (2:29 am)
Thanks Richard,Using a schedule actually works very well. I have a work around for the shift key, to simply bind it and set a clientside variable. So:
moveMap.bind(keyboard,lshift, shiftdown);
function shiftdown(%val)
{
LocalClientConnection.lshift = %val;
}function PlayGui::onMouseDown(%this, %modifier, %mousepos, %mouseclick)
{
//Save the cursor values
%mousepos = Canvas.getCursorPos();
LocalClientConnection.cursorX = getWord(%mousepos,0);
LocalClientConnection.cursorY = getWord(%mousepos,1);
LocalClientConnection.mouseisDown = 1;
if(LocalClientConnection.lshift){
%this.schedule(50, "mouseTurnCamera");
} else {
%this.schedule(50, "mouseDragged");
}
}
Torque Owner Richard Ranft
Roostertail Games
Might be a good idea to expose onMouseDragged() to the console. The function is there, so I'm not sure why it wasn't exposed.