The Daily Click ::. Forums ::. Klik Coding Help ::. Selecting Overlapping objects with the mouse
 

Post Reply  Post Oekaki 
 

Posted By Message

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
28th April, 2015 at 28/04/2015 18:43:27 -

Howdles clickeroonies

are you having a mighty clicky da..idk whats wrong with meanyways

I used to know how to fix this issue, but now my brain is agh.

I have several objects. When you click on a certain object, it changes color and brings up a menu yayayaya, that works all fine.
however, when an object overlaps another one (and this particular scenario requires that objects be able to overlap) it selects both objects, or if I set it to 'run this event once per tick' conditional modifier it will select the one that was created first (which would be the bottom object)

So, what kind of goofy workaround do I have to do in order to get it so when I click a set of intersecting objects, it selects the object on top? Do I need to do another object selection fastloop nonsense?

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

nim



Registered
  17/05/2002
Points
  7234
28th April, 2015 at 28/04/2015 23:10:28 -

The Layer Object has an "Object A is above Object B" condition that you'll probably find helpful.

e.g.

Mouse pointer is overlapping Button 1
AND [Layer Obj] Button 1 is above Button 2

 
//

Fifth

Quadruped

Registered
  07/05/2003
Points
  5818

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
28th April, 2015 at 28/04/2015 23:19:59 -

I've hit this very problem before. It's actually selecting the bottom-most object, and not the first-created.

What you can do is use the Layer Object to reverse all the objects when you click, then select the correct one, then reverse them back.

It'll be something like this:

- User Clicks on Active Object
+ run this event once

> [Layer Object] Reverse All
> [Active Object] Set Flag on (or whatever)
> [Some Other Object] Set another Flag on


- Some Other Object Flag is on

> [Layer Object] Reverse All

 
Go Moon!

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
28th April, 2015 at 28/04/2015 23:44:12 -


Originally Posted by nim
The Layer Object has an "Object A is above Object B" condition that you'll probably find helpful.

e.g.

Mouse pointer is overlapping Button 1
AND [Layer Obj] Button 1 is above Button 2



:c it didn't work. I tried it both with 'click on object' and 'user clicks + mouse overlaps object'
Also, it might help to mention that the overlapping objects are separate instances of the same object
I mean, the command works off of fixed numbers, but even that didn't circumvent the goofy object selection


Originally Posted by Fifth
I've hit this very problem before. It's actually selecting the bottom-most object, and not the first-created.

What you can do is use the Layer Object to reverse all the objects when you click, then select the correct one, then reverse them back.

It'll be something like this:

- User Clicks on Active Object
+ run this event once

> [Layer Object] Reverse All
> [Active Object] Set Flag on (or whatever)
> [Some Other Object] Set another Flag on


- Some Other Object Flag is on

> [Layer Object] Reverse All



:c didn't work either. My guess is that once you use the 'click on object' command, the engine has already selected which object it wants to click.

So with that, I guess the idea is to execute a fast loop that determines where the mouse is after the user clicks. I'll see if that works.

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
29th April, 2015 at 29/04/2015 01:02:52 -

You want the "Select Object" extension - it has conditions to select the frontmost / rearmost instance of an object.
Remember to pay attention to the order of conditions (it's important), and as you already figured out, don't use the "Player clicks on object" condition.

+ Mouse pointer is over Object
+ Player clicks left mouse button
+ Select Object: Select frontmost Object
-> Object: Do stuff...


Alternatively, the really inelegant way of doing it without extensions (and this only works if you haven't re-ordered them at runtime), would be something like this:

+ Mouse pointer is over Object
+ Player clicks left mouse button
-> Object: Spread value 0 in Alt.Val.A

+ Mouse pointer is over Object
+ Player clicks left mouse button
+ Alt.Val.A of Object = 0
-> Object: Do stuff...

Edited by Sketchy

 
n/a

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
29th April, 2015 at 29/04/2015 09:40:41 -


Originally Posted by Sketchy
You want the "Select Object" extension - it has conditions to select the frontmost / rearmost instance of an object.
Remember to pay attention to the order of conditions (it's important), and as you already figured out, don't use the "Player clicks on object" condition.

+ Mouse pointer is over Object
+ Player clicks left mouse button
+ Select Object: Select frontmost Object
-> Object: Do stuff...


Alternatively, the really inelegant way of doing it without extensions (and this only works if you haven't re-ordered them at runtime), would be something like this:

+ Mouse pointer is over Object
+ Player clicks left mouse button
-> Object: Spread value 0 in Alt.Val.A

+ Mouse pointer is over Object
+ Player clicks left mouse button
+ Alt.Val.A of Object = 0
-> Object: Do stuff...



Hmm, that's not doing it for me either :c

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

Fifth

Quadruped

Registered
  07/05/2003
Points
  5818

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
30th April, 2015 at 30/04/2015 02:33:44 -

Hmm, mine might not be working because of differences between MMF2 and CF2.5?
Anyway, I tried adjusting it a bit, and got one that should work in both versions.

Here's a (hopefully) working example file: http://www.l-ames.com/logan/mouse-select.zip

- User Clicks with Left Button
- Mouse Pointer is over [Active Object]

> [Layer Object] Reverse all
> [Another Object] Set Flag 0 On


- User Clicks with Left Button on [Active Object]
- Only one action when event loops

> [Active Object] Set Flag 0 on (to select it)


- [Another Object] Flag 0 is on

> [Layer Object] Reverse all
> [Another Object] Set Flag 0 Off

 
Go Moon!

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
1st May, 2015 at 01/05/2015 01:13:29 -

Ah, fuck yeah Fifth! I can finally get back to making progress again! You're a fucking life saver.

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal
   

Post Reply



 



Advertisement

Worth A Click