How do I make 2 object draggable only at the same time?

0 favourites
  • 11 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • I just can't figure it out how to do this:

    I want to make two objects draggable with touch, but they should be moving only when both of them are selected, if one of them is not selected anymore, the other stops the drag also.

    I've tried the disabeling expression, but then I have to touch it again when it's enabled.

  • You could use the pin behaviour to pin them together..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • actually what I mean is, that I don't want them to be moving the same way, but if I hold object1 down, then I can drag other object (the first one is at the same position, but can be moved if dragged). If I don't touch the object1 or object 2 anymore, then none of them is draggable.

  • One thing you may not have tried is, On start of touch, check to see if 2 items are selected. If not signal to drop the item. I am attaching an example which has 4 sprite objects. If 2 or more are selected, it will allow the user to drag the selected ones. If 1 or less is selected, none can be dragged. Understand, it is not production ready; it is just to show the method above.

    I hope this gets you what you need and good luck with your project.

  • Thanks for the example! Unfortunately it's not quite the thing I'm trying to do. I can make it so, that if 1 or less is selected, then none can be dragged, but problem is with the DragDrop. I'll try to explain..

    1). 2 different objects.

    2). If I try to drag only one of them I can't to it (that's correct and done).

    3). If I try to drag both of them (first one with touch0 and second one with touch1) only then it's possible (done).

    4). They're not pinned together, they can be dragged individually (if both of them are selected) (done).

    Problems:

    1). If the object1 is selected first and after that I select object2, then I can't drag object1 anymore because of the DragDrop what happens because at first only object1 is selected. (so I can drag both of them only when I touch both objects at the same time)

    2).If I select both objects(touch both objects at the same time) and then release only object1 (for example) and select object1 again, then object2 won't drag anymore because there was a DragDrop when I released the object1 (selected < 2 and then it drops the object)

    So I think it's not possible with DragDrop action unless there is a feature that allows automatic touch By that I mean when conditions met, then Touch.touch.

    I've also tried with "set position". But it still drags the object (maybe the drag overrides the set position action or maybe I just placed it in wrong place)

    Right now I'm out of ideas how to make it work, so I'd be very thankful if anyone finds solution

  • I guess if you use double tap to deselect it would be easier..

    tap to select, double tap to deselect..

    if two objects are selected create a new sprite with drag and drop on touch start and pin the two objects to it, on touch end destroy the new object.

    so, first select (not on touch start but on tap) and on a new touch (touch start) create the object..

    Something like that would probably solve the issue..

  • hmm, the game I'm making kinda loses it's point, when using tap and double tap. It would be better when object is draggable right from the moment of touch and deselects when released.

    I'm thinking that maybe it's better not to use the DragDrop behavior and make own custom drag&drop system? then I have little-bit more control over it.. or any other ideas?

  • Because it's not exactly clear to me what it is exactly what you want, I can't give any further advice, I'm sorry..

    Could be some issues in the way you implement the touchID, but I can't be sure..

    Multitouch is always tricky, I once made a onscreen joystick with fire-button and it took me a while to get the actions concerning the touchID right..

  • I finally figured it out and made it as I wanted.. almost.. There is still one bug, but I don't know why it occurs and how to fix it. It happens when I touch Red (for example) and then drag it, it seems that it isn't dragging but when I touch Green (still holding first touch),the Red one jumps to that position where I'm holding touch.

    I added the example project to attachments.

  • Nevermind, I fixed it!

  • There is still one bug, but I don't know why it occurs and how to fix it. It happens when I touch Red (for example) and then drag it, it seems that it isn't dragging but when I touch Green (still holding first touch),the Red one jumps to that position where I'm holding touch.

    VerteX123 - How did you fix this bug? I'm having the same issue with my game. The drag doesn't start working until the second touch for some reason. I've tried using Is In Touch, Is Touching Object and On any Touch Start and they are all producing the same bug.

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