Game Development Community

Setting up a variable condition for use onmousemove

by Isaac Barbosa · in Torque Game Builder · 09/10/2008 (10:15 am) · 5 replies

Hello,

I'm having problems with a global variable.

I'm setting up $canDrawSpriteLine to true on a onmousedown event.

So, this function should work:

function SceneWindow2D::onMouseMove(%this, %mod, %worldPosition)
{
   if($canDrawSpriteLine $= true)
   {
   $position = %worldPosition;
   player.createline();
}
}

function player::createline(%this)
{
   %humo = new t2dParticleEffect()
   {
      sceneGraph = %this.scenegraph;
      class = "humo2";
   };
   %humo.loadEffect("~/data/particles/lineagis.eff");   
   %humo.setPosition($position);
   %humo.setEffectLifeMode("kill", 0.3);
   %humo.playEffect();   
}

And it is working and I can draw a sprite after sprite line, but the problem is that the $canDrawSpriteLine true condition is not recognized until a onmouseup event. And then the creation of sprites starts.

So, how can I do to set the variable as true to be recognized at the right moment -that is exactly after the onmousedown-?

Thanks

#1
09/10/2008 (10:59 am)
Why not do that in the onMouseDown callback?
#2
09/10/2008 (11:19 am)
I'm doing that there. But the event doesn't works in the onmousemove unless I release the mouse first.
#3
09/10/2008 (11:19 am)
James you should try to understand what I mean if possible
#4
09/10/2008 (12:09 pm)
Ah, you should move your code in onMouseMove to onMouseDrag(ged?)
#5
09/10/2008 (12:24 pm)
@James,

Damn! I just forget that method!

Now is working as I want :)

Thanks!