alex_h Posted April 21, 2016 Share Posted April 21, 2016 (edited) I often have interactive sprites in different containers, some of which move around. This means I sometimes end up with two interactive sprites in different branches of the display tree but at the same global 'stage' co-ordinates. Currently this means that they will both respond to a mouse press or touch down event. I am looking for a simple way to detect that the sprite that is 'in front' has responded to the interaction and stop it from additionally triggering my event handler in the sprite that is 'behind'. I'm using pixi 3.09 [Edit] If I modify the pixi interaction manager so that when there is a hit it breaks out of its repeat loop then this achieves the effect I'm looking for. Would be interesting to know why it doesn't do this, is there some penalty I'm missing? for (var i = children.length-1; i >= 0; i--) { // time to get recursive.. if this function will return if somthing is hit.. if( this.processInteractive(point, children[i], func, hitTest, interactiveParent) ) { hit = true; // we no longer need to hit test any more objects in this container as we we now know the parent has been hit interactiveParent = false; // If the child is interactive , that means that the object hit was actually interactive and not just the child of an interactive object. // This means we no longer need to hit test anything else. We still need to run through all objects, but we don't need to perform any hit tests. if(children[i].interactive) { hitTest = false; } break;//<<< ---- I just have to add this and then it works } } Edited April 21, 2016 by alex_h further info Quote Link to comment Share on other sites More sharing options...
themoonrat Posted April 21, 2016 Share Posted April 21, 2016 Try the latest v3 build, 3.0.11. It has changes to the interaction manager which solves this issue I believe Quote Link to comment Share on other sites More sharing options...
alex_h Posted April 21, 2016 Author Share Posted April 21, 2016 Ah nice one, I'll have a look - thanks! Interesting - they've added the same break I did but its now commented out... Have to give it a try anyway I guess Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.