Game Development Community

SetMousePosition vs windows environment cursor position

by Jason Howard · in Torque Game Builder · 05/14/2006 (1:13 pm) · 1 replies

I'm using the following code:
function sceneWindow2D::onMouseMove(%this, %modifier, %worldPosition, %mouseClicks) 
{
	%newPaddleX = getWord(%worldPosition, 0);	// get new mouse X position
	%newPaddleX = getWord(%worldPosition, 0);	// get new mouse X position
	%deltaX = %newPaddleX - $oldPaddleX;		// see how far it's moved in the X direction
	movePlayerPaddle(%deltaX);				// move the player		
	$oldPaddleX = %newPaddleX;			// remember where the mouse was at for future comparisons
}


It works great with single-monitor full screen... but in windowed mode, you lose mouse control of the paddle when the mouse leaves the T2D window and becomes the windows mouse cursor outside the application. Trying a trickly little hack like adding "sceneWindow2D.setMousePosition("0, 0");" at the end of the function doesn't solve the problem, because it doesn't reset the mouse position from a Windows environment point of view.

So, is there a way to force the mouse to stay inside the T2D applications & take it completely away from windows? I tried setting sceneWindow2D.lockMouse to true, to no avail. I also tried calling "sceneWindow2D.setLockMouse(true);"...

I'm sure I'm just missing something obvious.

#1
05/14/2006 (1:21 pm)
Just because it will probably come up, I also tried binding mouse0 xaxis, but wasn't able to get that binding to call my function. I tried to follow the advice in older threads (www.garagegames.com/mg/forums/result.thread.php?qt=26532), but cursorOff() doesn't seem to work anymore (?) to switch from GUI mode to control mode. I'm probably missing something simple there, too...