Game Development Community

Mouse movement?

by Denis Linardic · in Torque Game Builder · 10/08/2005 (3:52 am) · 2 replies

Hi guys!

I am new to T2D and this is probably a stupid question, but can you give me example on how to create mouse movement for spacescroller.

I know how to bind mouse button to fire, but I don't know how to detect mouse move up -> Ship move up....

I work with tge for over 2 years but I never need something like that. I've read in TDN and docs that T2D supports mouse movement, so I am asking for a few guidelines..


Thanks!

#1
10/08/2005 (4:59 am)
Mouse Fire works great, but movement....
Well I am using this code.

new ActionMap(playerMap);
	
	// Create Player Map.
      cursorOff();
    //Deno dodao Mouse control
    playerMap.bindCmd(mouse, button0, "playerFire();", "playerFireStop();");
    playerMap.bind( mouse, "yaxis", handleMouseY );
    playerMap.bind( mouse, "xaxis", handleMouseX);
	playerMap.bindCmd(keyboard, "w", "playerUp();", "playerUpStop();");
	playerMap.bindCmd(keyboard, "up", "playerUp();", "playerUpStop();");
                ....And so on....

function handleMouseY( %val )
{
 echo( "MouseY" SPC %val );
 $MouseY = %val;
}

I am pretty sure that error lies here...

function playerUp()
{
	// Set it moving up.
	//$player.setLinearVelocityY( -$movementSpeed );
 $player.setLinearVelocityY(-$MouseY );
}

My guess is that player.setLinearVelocity is the problem, I've tried with setPosition but nothing happens. Console doesn't give any error.
Any Ideas???
#2
10/08/2005 (5:36 am)
I figured this one, it was my fault as usual ;)

Great Engine I must say!!!