Overflowz Posted February 23, 2016 Share Posted February 23, 2016 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 More sharing options...
fillmoreb Posted February 23, 2016 Share Posted February 23, 2016 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. Overflowz 1 Link to comment Share on other sites More sharing options...
Overflowz Posted February 23, 2016 Author Share Posted February 23, 2016 Thank you! I'll try that! fillmoreb 1 Link to comment Share on other sites More sharing options...
Overflowz Posted February 23, 2016 Author Share Posted February 23, 2016 Hey! it works like a charm with using only Phaser. I also tried it on QICI Engine, but sadly it's not getting fired at all (startDrag function). Anyways, if you know any solution on this, it could help too! Also, topic is solved, thanks again! Regards. Link to comment Share on other sites More sharing options...
Overflowz Posted February 26, 2016 Author Share Posted February 26, 2016 in case someone needs it, here's the implementation. different one, but works as expected http://ask.qiciengine.com/?/question/24?notification_id=175&rf=false&item_id=98#!answer_98 Regards. Link to comment Share on other sites More sharing options...
Recommended Posts