Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Remove "rubber band" effect from sprite dragging


RogueBurger
 Share

Recommended Posts

I've just been diving into the framework for the first time today, and having a blast; however I have run into a snag that I can't seem to find the answer to. I have a sprite and I successfully enabled dragging on it with ( mySprite.inputEnabled = true; mySprite.input.enableDrag(); ), however when I drag it around it falls behind the cursor, and then "rubber bands" back to the cursor's location when I stop moving it. Is there any way to stop this from happening, and instead have the sprite stick to exactly where the cursor is?

 

 

Link to comment
Share on other sites

  • 2 weeks later...

here's a fix for that:

 

sprite.inputEnabled = true;sprite.input.enableDrag(false);sprite.events.onDragStart.add(function(){ arguments[0].body.gravity.y = 0; arguments[0].body.gravity.x = 0; },this);sprite.events.onDragStop.add(function(){ arguments[0].body.gravity.y = GRAVITY_Y; arguments[0].body.gravity.x = GRAVITY_X; },this);

 

with GRAVITY_X and GRAVITY_Y being your values you set to that certain 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...