How do I separate Drag Drop and Click?

0 favourites
  • 7 posts
From the Asset Store
High quality sound effect pack, in the following categories: Simple, negative, pozitive
  • When I click a tile sprite I want it to rotate which is no problem.

    When I drag a tile onto a grid I want it to pop into place by doing an onOverlap, Set Position,Play SFX(snapping sound).

    The problem is clicking the sprite to rotate it triggers the DragDrop. So it repeats the DragDrop code when rotating. I've tried with various booleans, but it seems like separating the two functions is not easy.

    Is anyone else using drag/drop with being able to rotate sprites?


  • Just a guess since you don't have a capx to look at.

    I would separate them by using right click for rotate and left click for drag and drop.

    If you are using a touchpad it could be On Object double tap for rotate

    On object tap and hold for drag and drop

  • There are probably better ways to do this but here's what I'd do with my limited knowledge of C2.

    The problem I encountered with Drag and Drop is that if you try and enable and disable the Drag and Drop function Mid-click it doesn't work. I think for it to be "Drag and Drop" you really have to click on the sprite on click/touch start.

    So I created a Timer that sets your button to the default position when a certain "Click Time" variable hasn't been surpassed yet. This is my workaround to override the Drag and Drop function. Note this capx isn't perfect yet.

    Please share your solution if you manage to fix my CAPX: ... .capx?dl=0

  • Or something like this. ... .capx?dl=0

    Even better. Mine was super complicated... <img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing">

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Or something like this. ... .capx?dl=0

    I like this approach.. so you are 'overloading' the dragdrop behavior by saying if they started the drag drop behavior and they didn't actually drag it anywhere (stays in same place) then treat that as a single click, otherwise treat it as a normal drag/drop.

    awesome.. perfect, that is EXACTLY what I was looking for... thanks!

    in my opinion the Drag/Drop behavior is faulty... isDragging should not turn TRUE until the X/Y has actually changed to separate it from the single left-click. Instead it turns TRUE as soon as you click it...which is wrong logically (since I only clicked it) and wrong practically since I now have to jump through hoops to get a single click trigger separated.

  • thank you community for helping me to figure it out... you rock as usual!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)