Game Development Community

Finding if a certain image is below my cursor

by Bruno · in Torque Game Builder · 06/17/2007 (3:53 am) · 6 replies

This is the ideia, i move my cursor around, and i click in an image.
I need to know if that image was clicked or not.
I know how to do this with tilemaps, and finding if the mouse was clicked in a cell, but i don't want to use
tilemaps.

I was thinking in having an invisible image, that when i clicked with the mouse in a area of the screen, i would move that image to the cursor and check collision between the invisible image and the image i was clicking on.
So, my questions would be, is there a simpler "less messy way" of knowing if i'm clicking on a image ? (by image, imagine a situation like a hide & seek game like Raven mysterie files where you have a background, and then for example a image of a rabbit somewhere in the screen).

thanks

#1
06/17/2007 (4:31 am)
tdn.garagegames.com/wiki/TGB/Reference:_t2dSceneObject_Callbacks#onMouseDown.28....

Thats the callback page for t2dsceneobjects. There are bunch of mouse callbacks you can use. That's probably the easiest/less messy way ;)
#2
06/17/2007 (6:27 am)
Thanks, altough i don't quite get it how to use it.
Ok, i have a static image,
i gave it a class name "lemon" and enabled "Use mouse events" on it.

Now, i do i get a callback on him ?

i did,

function lemon::onMouseDown( %this, %mod, %worldPos, %mouseClicks )
{
echo("LIMAO");
}

But still doens't work.
#3
06/17/2007 (6:36 am)
Actually, i don't think we can use this, because that callback is from t2dsceneobjets.
#4
06/17/2007 (6:43 am)
Ok, managed to get it working :)
#5
06/17/2007 (11:18 am)
How did you do that? using a onMouseEnter callback?
#6
06/17/2007 (2:44 pm)
Nope, using a onMouseUp for the image itself.
I declared a class, like above, class lemon

function lemon::onMouseUp(%this, %modifier, %worldPosition, %clicks)
{


and activated this option for the general window manager :

sceneWindow2D.setUseObjectMouseEvents(1);

and that's it