Jump to content

How to know if NO sprites are clicked?


Rammschnev
 Share

Recommended Posts

I am working on a project in which the user creates a system of points by adding them one-at-a-time. These points are also draggable, and clicking on existing points sets the clicked point as active. That's all working fine. When using a simple mouseDownCallback, clicking one of these existing points creates interference between the activities of the new point and the old point.

I want to be able to determine what sprites, if any, a clicked point contains and run a function only if the spot is unoccupied. If I can do this via the activePointer versus specifically mouse, that's preferred, but not necessary. Can someone point me in the correct direction?

Link to comment
Share on other sites

I don't know of a way to find out if no sprites were clicked. I can think of a couple of solutions?

What if you had a big, invisible sprite that was behind all the other sprites, drawn in a black color so that it was invisible. If someone clicks that sprite then they didn't click any of the others (because they'd get the click notification)?

Depending on how many sprites you have, you could also loop through each one and see if it was clicked by checking its bounds manually, as it were. For loops can be pretty fast.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...