Game Development Community

Mouse Input

by Dan Phillips · in Torque Game Builder · 09/28/2006 (5:32 pm) · 2 replies

Excuse my programming noobness.

I see that there are two ways to get input, callbacks and actionmaps. I read about how they are used buy I don't understand why I would use one over the other. What I'm guessing is callbacks you put in an object and actionmaps are something that setup the input for the whole game?

Also, I'm trying to get the mouse to work. Here's what I've got so far. Nothing works, no idea why. I've got a sprite in the editor named pCanon and class canonClass. This file is being executed from game.cs.

function canonClass::onLevelLoaded(%this, %scenegraph)
{
	//set the player's ship name to the instance
	$pCanon = %this;
	
	// make sure the scene window is set to send mouse events to objects
	if(!sceneWindow2D.getUseObjectMouseEvents())
	{
		sceneWindow2D.setUseObjectMouseEvents(true);
	}

	// set this object to accept mouse events
	%this.setUseMouseEvents(true);
	
	echo("blah");
}

function canonClass::onMouseDown(%this, %modifier, %worldPosition, %clicks)
{
	echo("mouse down");
}

function canonClass::onMouseUp(%this, %modifier, %worldPosition, %clicks)
{
	echo("mouse up");
}

function canonClass::onMouseMove(%this, %modifier, %worldPosition, %clicks)
{
	echo("mouse move");
}

function canonClass::onMouseDragged(%this, %modifier, %worldPosition, %clicks)
{
	echo("mouse dragged");
}

#1
10/24/2006 (2:29 pm)
Did you enable the mouse inside tgb gui?
#2
10/24/2006 (6:45 pm)
I figured it out.