Knowing where a sprite is leaved
by Isaac Barbosa · in Torque Game Builder · 03/11/2007 (1:25 pm) · 5 replies
Hi,
I'm wondering if there is a way to know and save the point where the mouse leaves a sprite. I mean top, bottom, right or left limits, so I can attach a new sprite on that position.
Thanks
I'm wondering if there is a way to know and save the point where the mouse leaves a sprite. I mean top, bottom, right or left limits, so I can attach a new sprite on that position.
Thanks
#2
Well, I'm linking some letter in my game to make words. If I click over an "A" -for example-, and then I leave that "A" toward another tile I want to add a little arrow between those two letters... but I will leave "A" from top, bottom, left or right... so how will I know the right direction of the leaving? I don't know if this makes sense... but if I use this, the arroe is attached to the center of "A"...
I just need to figure if the mouse is leaving the "A" sprite from its top, bottom, right or left limit so I will attach the arrow in that position.
03/11/2007 (4:41 pm)
Hey David, Thanks again ;)Well, I'm linking some letter in my game to make words. If I click over an "A" -for example-, and then I leave that "A" toward another tile I want to add a little arrow between those two letters... but I will leave "A" from top, bottom, left or right... so how will I know the right direction of the leaving? I don't know if this makes sense... but if I use this, the arroe is attached to the center of "A"...
%this.arrow = new t2dStaticSprite()
{
scenegraph = %this.scenegraph;
class = "arrow";
};
%this.arrow.setPosition(%this.getPosition());
%this.arrow.setImageMap("arrowImageMap");
%this.arrow.setSize(2, 2);I just need to figure if the mouse is leaving the "A" sprite from its top, bottom, right or left limit so I will attach the arrow in that position.
#3
This would actually be the preferred method, as it requires less calls through the scripting engine since the datablock is processed all together ... where as your method above requires 4 calls ... the creation of the object, then 3 object-level function calls ...
If you were to compare the two methods, by creating say 100,000 objects ... the latter would finish first ...
As for the rest of your post, it doesn't make much sense ...
There are functions for retrieving the position of the mouse,
Which will tell you where the mouse is currently located at any given point in time ... outside of telling you this, and that %worldPosition is the location of the mouse at the time a mouse callback is used (onMouseUp, onMouseDown, onMouseDragged, etc) ... I don't know what else to say.
03/11/2007 (4:55 pm)
@Isaac, first ... your datablock for the arrow could be done this way:%this.arrow = new t2dStaticSprite()
{
scenegraph = %this.scenegraph;
class = "arrow";
position = %this.getPosition();
imageMap = "arrowImageMap";
size = "2 2";
};This would actually be the preferred method, as it requires less calls through the scripting engine since the datablock is processed all together ... where as your method above requires 4 calls ... the creation of the object, then 3 object-level function calls ...
If you were to compare the two methods, by creating say 100,000 objects ... the latter would finish first ...
As for the rest of your post, it doesn't make much sense ...
There are functions for retrieving the position of the mouse,
sceneWindow2D.getMousePosition();
Which will tell you where the mouse is currently located at any given point in time ... outside of telling you this, and that %worldPosition is the location of the mouse at the time a mouse callback is used (onMouseUp, onMouseDown, onMouseDragged, etc) ... I don't know what else to say.
#4
03/11/2007 (6:13 pm)
@ David, well, if anything, it helped me to figure out some things for my game plan. :D Thanks. :)
#5
Thanks for the clarification with the function. You have say enough, with that I know now what to do, at least I have clarification on the path I have to walk :)
03/12/2007 (8:31 am)
@David:Thanks for the clarification with the function. You have say enough, with that I know now what to do, at least I have clarification on the path I have to walk :)
Associate David Higgins
DPHCoders.com