Custom Cursor
by Josh Isaak · in Torque Game Builder · 03/06/2005 (9:08 pm) · 12 replies
I am trying to create a custom cursor in lieu of the default arrow.
It works fine until I call cursorOff() and then ceases to work. As soon as a I display then hide the console and the cursor reappears it works fine. What am I doing wrong?
=====
function setupT2DScene()
{
// Create fxSceneGraph2D.
new fxSceneGraph2D(t2dSceneGraph);
// Associate Scenegraph with Window.
sceneWindow2D.setSceneGraph( t2dSceneGraph );
// Set Camera Position to be centered on (0,0) with
// view width/height of (100/80).
sceneWindow2D.setCurrentCameraPosition( "0 0 100 75" );
sceneWindow2D.setUseMouse( true );
loadImages();
createCursorSprite();
cursorOff();
}
function createCursorSprite()
{
$cursor = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
$cursor.setImageMap(cursorImageMap);
$cursor.setSize( "5 5" );
}
function loadImages()
{
datablock fxImageMapDatablock2D(cursorImageMap)
{
mode=full;
textureName = "~/client/images/crossHair";
};
}
function sceneWindow2D::onMouseMove( %This, %Modifier, %WorldPosition, %MouseClicks )
{
%x_pos = getWord(%WorldPosition,0);
%y_pos = getWord(%WorldPosition,1);
$cursor.setPosition(%x_pos SPC %y_pos);
}
It works fine until I call cursorOff() and then ceases to work. As soon as a I display then hide the console and the cursor reappears it works fine. What am I doing wrong?
=====
function setupT2DScene()
{
// Create fxSceneGraph2D.
new fxSceneGraph2D(t2dSceneGraph);
// Associate Scenegraph with Window.
sceneWindow2D.setSceneGraph( t2dSceneGraph );
// Set Camera Position to be centered on (0,0) with
// view width/height of (100/80).
sceneWindow2D.setCurrentCameraPosition( "0 0 100 75" );
sceneWindow2D.setUseMouse( true );
loadImages();
createCursorSprite();
cursorOff();
}
function createCursorSprite()
{
$cursor = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
$cursor.setImageMap(cursorImageMap);
$cursor.setSize( "5 5" );
}
function loadImages()
{
datablock fxImageMapDatablock2D(cursorImageMap)
{
mode=full;
textureName = "~/client/images/crossHair";
};
}
function sceneWindow2D::onMouseMove( %This, %Modifier, %WorldPosition, %MouseClicks )
{
%x_pos = getWord(%WorldPosition,0);
%y_pos = getWord(%WorldPosition,1);
$cursor.setPosition(%x_pos SPC %y_pos);
}
#2
03/06/2005 (10:35 pm)
Guess I left out the fact that it displays both my sprite and the default pointer. I'm trying to stop the display of the default pointer.
#3
03/06/2005 (10:44 pm)
new GuiCursor(CustomCursor)
{
hotSpot = "1 1"; // Set this to the X/Y coordinate of where you want the hotspot
bitmapName = "~/client/images/crossHair";
};
Canvas.setCursor(CustomCursor);
#4
03/06/2005 (10:51 pm)
Perfect, thanks!
#5
Greg
09/30/2007 (5:26 am)
This no longer seems to work for me in 1.5.1, at least on Mac. My custom cursor displays, but the default cursor displays as well. Worked fine in 1.3 obviously.Greg
#6
10/10/2007 (9:03 pm)
Works for me in 1.5.1 Windows.
#7
Greg
10/11/2007 (3:25 pm)
Yes, in the bug forum I posted that this was a problem on the Mac version only.Greg
#8
11/11/2007 (10:15 am)
I've got the default pointer drawing over the cursor I set with setCursor(blah) as well and I'm in windows. Using latest release of TGB. Any suggestions on how to get rid of this?
#9
Also, there seems to be a noticeable lag between the mac cursor and the trailing custom cursor.
is there a way to reduce that?
12/08/2007 (2:49 pm)
Is there a fix for the Mac version? Works fine in Windows w/1.5.1, but not on Macs.Also, there seems to be a noticeable lag between the mac cursor and the trailing custom cursor.
is there a way to reduce that?
#10
12/08/2007 (5:10 pm)
The code Harold posted should really be working on all supported platforms.. if it isn't I'd consider it a bug. You can always use a sprite and continually set its position to the current mouse position. That way you'll also have the added benefit of animation.
#11
So I guess my next question is - is there a fix for this? Or at least a different way to hide the default OS cursor?
12/08/2007 (7:09 pm)
Joe - the code Harold posted works fine in Windows, but on a Mac it shows both the custom cursor and the default Mac cursor. So I guess my next question is - is there a fix for this? Or at least a different way to hide the default OS cursor?
#12
I just compiled my game on Mac and seem to have the same problem using tgb 1.7.2 . I'm getting both the default cursor and my custom cursor. On PC I only get the custom one.
Did you guys figured it out?
05/27/2008 (12:15 pm)
Sorry for joining in so late on this.I just compiled my game on Mac and seem to have the same problem using tgb 1.7.2 . I'm getting both the default cursor and my custom cursor. On PC I only get the custom one.
Did you guys figured it out?
Torque Owner Jason McIntosh