Jump to content

DragStartEvent on click


Overflowz
 Share

Recommended Posts

Hello folks, I'm trying to make drag event to be fired on 'onClick' event, save state that it's being dragging and with second pressing it should fire drop event. I was thinking and trying so many ways, but could not do anything at all. Could someone help me please?

 

Regards.

Link to comment
Share on other sites

You're trying to make a "sticky" drag and drop, right?  Click on a Sprite, then it follows the cursor until you click again? 

If I understand what you're trying to do, you have the order of events backwards.  Firing the onDragStart event does not initiate dragging.  The function startDrag() is what fires onDragStart to let you know that dragging has already begun.

What you could try doing is calling the startDrag() function on sprite.input in your onClick event.  Then, on the second click, call stopDrag().  The startDrag() function sets the property this.isDragged to true, so you can probably use that to determine whether to call startDrag() or stopDrag() in the onClick event.

Note: startDrag() and stopDrag() are properties of the sprite's InputHandler.  Use mySprite.input.startDrag() etc.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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