How to make drag and drop application

  • I am new to construct 2, trying to make a application to match boxes as per given layout. For this I want to use drag and drop functionality to match the block.

    Can any body help me ?

    Thanks in advance

    Kiran

  • Well,first,make the object you want to drag(A rock,for example)then create a number variable named dragged for the rock.

    Left Mouse button clicked                  -"Rock"-set "dragged" to 1

    "rock" isn't overlapping "rock"            -

    -------------------------------

    Left mouse button is down                  -"Rock"-set position to "mouse"

    "rock" dragged is 1                        -

    -------------------------------

    On left button released                    -"Rock"-set "dragged" to 0

    And there ya go,hope it helped :D

  • Here is an example I made previously for someone else.

    Click Inventory Example

    I hope it helps.

  • drag&drop for ya

    drag%26drop.capx

  • Here's an example that picks the topmost object under the mouse and move it on top of the others when dragged. I thinks this makes it a more intuitive behavior.

    Example

  • Yeah anim I saw rojo post a capx on emulating a "pick top most" behavior but I was too lazy to implement it :D... my capx is an old one I made like a month and half ago.

  • Animmaniac, nice example. I will start using your method instead.

  • Thanks to all of your contribution, given examples helps me lot.

  • It helped, thanks!!

    But when I click CTRL +A and then try to drag the objects, its drag the complete background. It is only worked proper when I refresh the html page.

  • Very useful... I will use the example of Yann =)

  • ROJOhound posted a couple of good Drag and Drop/Snap to grid example's on the Construct Classic forums yesterday.

    Obviously you will need Classic on your system to view them.

    LINK

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi!

    I came across your example. It is very helpful. The only thing I'm having trouble understanding is, the expressions part. Like how do you determine the position of the area which you want the draggable elements to be reverted back to if it overlaps with another element...?

    Can I just set the position manually without all those expressions?

    Do you have a tutorial on this example?

    Thank you so much :)

  • Hi!

    I noticed that your drag and drop example, actually has specific areas for the draggable elements to be dropped into. As in, objDiamond is set for objDiamondTarget.

    I would like to

    1) make draggable elements able to to be dropped into any droppable areas. 2) And if it overlaps with another element, it will revert back to its original position.

    Which part of your event sheet explains these points?

    I hope to hear from you soon.

    Thank you. :)

  • thnaks Yann for your great Example

  • Yann and Wastrel your examples are not opening

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