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

Just started using Construct 2? Post your questions here

Post » Fri Jul 18, 2014 5:01 pm

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.
B
3
Posts: 8
Reputation: 191

Post » Fri Jul 18, 2014 5:36 pm

You could use the pin behaviour to pin them together..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Jul 18, 2014 6:10 pm

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.
B
3
Posts: 8
Reputation: 191

Post » Fri Jul 18, 2014 6:21 pm

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.
You do not have the required permissions to view the files attached to this post.
B
39
S
12
G
11
Posts: 331
Reputation: 7,727

Post » Sat Jul 19, 2014 9:36 am

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 :)
B
3
Posts: 8
Reputation: 191

Post » Sat Jul 19, 2014 12:21 pm

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Jul 19, 2014 1:23 pm

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?
B
3
Posts: 8
Reputation: 191

Post » Sat Jul 19, 2014 7:51 pm

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 told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Jul 20, 2014 8:36 am

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.
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 8
Reputation: 191

Post » Sun Jul 20, 2014 9:20 am

Nevermind, I fixed it! :)
B
3
Posts: 8
Reputation: 191

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest