Jump to content

Clicks fall through sprites


noom
 Share

Recommended Posts

Hello,

I'm working on a close source project so the amount of example code I can supply is relatively limited, so let me see if just simply describing my problem will help.

We have three containers, linePoints and lineSegments, these containers are children of the line container.

They are all interactive and in buttonMode

We have two types of sprites, the points, and segments, these are children within their respective containers. These sprites are created also interactive and in buttonmode with events tied to them. Points get all of the drag related events (mosedown, mouseup etc) and Segments get just the click event.

The structure :

line(container, interactive)

  -linePoints(container, interactive)

      -points(sprite, interactive, draggable)

  -lineSegments(container, interactive)

      -segments(sprite, interactive, clickable)

 

The problem :

My points are drawn on top of the line segments, yet when I click on them to drag them around, this fires the click event on the lines lying beneath them (which actually creates a new point, so things get a bit messy)

So my question is, are click events supposed to fall through sprites and activate on sprites underneath them in the draw order?

If so then is there a way to properly block this from happening ?

 

What I've tried :

binding null to the click event on the points: point.on("click", null)

debinding the click event on the points : point.off("click") - thought I couldnt actually find documentation on .off() so I'm not sure this even does anything

changing the size of my points to be absolutely sure they are covering the lines - the clicks are definitely "falling through" and not just sneaking around, I'm clearly getting two interaction events at the same time here, one on the point when I mousedown to drag, and one on the line underneath it.

 

So there's my issue, if this really isn't enough to explain or illustrate the problem, I can make a fiddle on request, but I'd like to avoid doing the extra work if it's not required. It's efficiency not laziness!

 

Thanks all in advance

Link to comment
Share on other sites

4 minutes ago, Shaun Dreclin said:

Just sayin', there's no such thing as a closed source JavaScript game. :P

It's actually a web app and won't be delivered via a traditional web page, but this is beside the point, why don't we just say that I'm bound by my parent company at this stage to avoid sharing source code :D

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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