[Solved]canvas.setCursorPos does it with a slight offset Why?
by Vlad I · in Torque Game Builder · 09/12/2012 (12:59 pm) · 3 replies
I have an object Pincers in my scene and I want my mouse to become this object and set position where it is.
It all works only with the slight offset from where the cursor should take place.
I can't figure out why this happens, no errors.
Here is the code:
What do I miss?
It all works only with the slight offset from where the cursor should take place.
I can't figure out why this happens, no errors.
Here is the code:
function PincersGrasp01Class::onAnimationEnd(%this)
{
Canvas.setCursor(PincersGearCursor01);
%worldPos = PincersGear01.getPosition();
%windowPos = sceneWindow2D.getWindowPoint( %worldPos );
//canvas.setCursorPos( %windowPos );
canvas.setCursorPos( getWord(%windowPos,0), getWord(%windowPos,1) );
}What do I miss?
About the author
Torque Owner RollerJesus
Dream. Build. Repeat.
It's hard to say without seeing the image for PincersGearCursor01 but I think that when you set the cursor at the point you got in %windowPos, TGB sets the top left of that image to where the mouse was clicked. So if there is any transparency around the image, then there is a little offset that remains.
Try to figure out how many pixels there are on the x and y axes (%xOffset and %yOffset) between the top left of that image and where you want the actual click point of the PincersGearCursor01 and compensate for that in the setCursorPos call.
If you want it to set to the center of the image, you could do something like this: