Recomended method of Mouse Movement
by Greg Squire · in Torque Game Builder · 01/10/2007 (5:43 pm) · 2 replies
In becoming more familiar with TGB, it appears there are two ways to deal with the mouse
First is via mouse events in the SceneWindow2D object (such as)
function SceneWindow2D::onMouseMove(%this, %mod, %worldPosition)
{
%this.mouseMoveShip(%mod, %worldPosition);
}
function sceneWindow2D::onMouseDragged(%this, %modifier, %worldPosition, %mouseClicks)
{
%this.mouseMoveShip(%mod, %worldPosition);
}
function sceneWindow2D::onMouseDown(%this, %mod, %worldPosition, %mouseClicks)
{
$pShip.isFiring();
}
Or via the bind and bindCmd handlers (such as)
playerMap.bindCmd(mouse, button0, "playerFire();", "playerFireStop();");
playerMap.bind( mouse, "yaxis", handleMouseY );
playerMap.bind( mouse, "xaxis", handleMouseX);
I'm developing a full screen shooter that will use the mouse to control the ship (cursor will be turn off in game and back on when in menus). So, I'm wondering what's the recommended method to use (the one that might give me less grief perhaps). Ideas?
First is via mouse events in the SceneWindow2D object (such as)
function SceneWindow2D::onMouseMove(%this, %mod, %worldPosition)
{
%this.mouseMoveShip(%mod, %worldPosition);
}
function sceneWindow2D::onMouseDragged(%this, %modifier, %worldPosition, %mouseClicks)
{
%this.mouseMoveShip(%mod, %worldPosition);
}
function sceneWindow2D::onMouseDown(%this, %mod, %worldPosition, %mouseClicks)
{
$pShip.isFiring();
}
Or via the bind and bindCmd handlers (such as)
playerMap.bindCmd(mouse, button0, "playerFire();", "playerFireStop();");
playerMap.bind( mouse, "yaxis", handleMouseY );
playerMap.bind( mouse, "xaxis", handleMouseX);
I'm developing a full screen shooter that will use the mouse to control the ship (cursor will be turn off in game and back on when in menus). So, I'm wondering what's the recommended method to use (the one that might give me less grief perhaps). Ideas?
#2
The Scene Window mouse callbacks are ideal for most situations... with the bind commands being an option in case that sort of input is preferred. If you are unsure then just go with the Scene Window callbacks :)
01/22/2007 (4:18 pm)
I would agree with what Tom said.The Scene Window mouse callbacks are ideal for most situations... with the bind commands being an option in case that sort of input is preferred. If you are unsure then just go with the Scene Window callbacks :)
Associate Tom Eastman (Eastbeast314)
I'd recommend activating useObjectMouseEvents and then turning on useMouseEvents on the menu buttons and stuff - and then just using that to make the menu.
Hope that made sense - I can ramble more about specifics if you'd like.