The Daily Click ::. Forums ::. Klik Coding Help ::. Drag and Drop?
 

Post Reply  Post Oekaki 
 

Posted By Message

eX Com



Registered
  15/08/2002
Points
  352
11th November, 2007 at 19:54:46 -

Is there a simple way to do drag and drop with several objects so that only the object with the frontmost order will be picked (incase some are overlapping)? I'm using MMF2.

 
The chickens are coming...

eX Com



Registered
  15/08/2002
Points
  352
12th November, 2007 at 16:26:01 -

oh come on, no one knows? I have a way that works if two objects are overlapping but anything greater than two I just can't figure out. I'll give whoever figures it out a cookie.

 
The chickens are coming...

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
12th November, 2007 at 16:29:57 -

Spread a value. It'll treat the backmost object as the object with the lowest spread value, and the frontmost as the object with the highest value.

 
Old member (~2004-2007).

eX Com



Registered
  15/08/2002
Points
  352
12th November, 2007 at 16:45:08 -

okay can u explain what that is (i'm semi-new at this). or make an example?

 
The chickens are coming...

eX Com



Registered
  15/08/2002
Points
  352
12th November, 2007 at 17:41:29 -

i get the spread value thing sort of I just don't know how to implement it..

 
The chickens are coming...

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
13th November, 2007 at 09:25:51 -

Hm, I see. It's difficult to get the object with the highest value here. I suggest that you try something like this:

First, add a new counter to the application, which starts out at 0. Then add these events:

1 Start of level:
spread 0 in value A in object
2 On mouse click on object
+ object is overlapping object:
Spread 0 in value B in object, start loop "check overlaps" 20 times (could be more if you think more objects than that will overlap).
3 On loop "check overlaps"
+ value B = loopIndex("check overlaps") (to get each overlapping object individually each part of the loop)
+ value A > counter:
Set counter to value A of object

In the end you'll get a value in the counter that determines the highest value A out of these objects. Then it's a matter of picking that object (counter = value A) and setting that specific object to "drag mode".

 
Old member (~2004-2007).

eX Com



Registered
  15/08/2002
Points
  352
21st November, 2007 at 15:26:51 -

I tried it but it didn't work. Can you make an example? When two objects overlap, the counter jumps to 8 and neither of the objects can be moved.

 
The chickens are coming...

eX Com



Registered
  15/08/2002
Points
  352
21st November, 2007 at 16:06:01 -

okay i sort of understand the problem.. it doesn't assign the lowest spread value to the object furthest back.. its completely random

 
The chickens are coming...

eX Com



Registered
  15/08/2002
Points
  352
21st November, 2007 at 17:05:18 -

ugh why is this so difficult. I got it to work but now if there are two separate groups of overlapping objects, you can only pick from the one group.. anyone have an easier way to do this?? Drag and drop with overlapping objects where it picks the one with the frontmost order first. you would be my hero!


 
The chickens are coming...

Fifth

Quadruped

Registered
  07/05/2003
Points
  5815

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
21st November, 2007 at 17:21:43 -

Well, I don't know if this helps, but...

I recently had a similar problem, where I wanted to be able to click to select an object of many overlapping objects, and have it always select the front object.
I tried the condition limiter "only one action when event loops" to have it only select one single object, but that would, without fail, select the object furthest back.

Now, as it happened, I was sorting all of the objects on the screen by an alterable value using the layer object. I simply had it reverse the order it was sorting by when I clicked, and the reverse it back afterwards. Thus the front object would be selected, and everything would be in its proper order.

Even if you're not sorting your objects like that, you might still be able to use the layer object to your advantage.
Try something like this:

- User clicks left button
Set some flag ON
Reverse all (layer object)

- User clicks left button on Active
+ Only one action when event loops
(Select Active)

- Some flag is ON
Set some flag OFF
Reverse all (layer object)


...or something similar. You'd select the front object, and the objects' order wouldn't be disturbed.

...and I hope I understood this correctly.

 
Go Moon!

eX Com



Registered
  15/08/2002
Points
  352
21st November, 2007 at 18:30:33 -

how do you reverse all, all at once?

 
The chickens are coming...

Fifth

Quadruped

Registered
  07/05/2003
Points
  5815

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
21st November, 2007 at 18:33:24 -

You have the Layer Object, right?

It's one of its actions, under "Sort".

 
Go Moon!

eX Com



Registered
  15/08/2002
Points
  352
21st November, 2007 at 23:27:37 -

yep! i got it working. thanks alot!

 
The chickens are coming...
   

Post Reply



 



Advertisement

Worth A Click