intoxopox Posted February 23, 2017 Share Posted February 23, 2017 Is there a good reason containsPoint method couldn't be moved down to Container and examine children, since it's already on Graphics, Sprite, Mesh, etc? Quote Link to comment Share on other sites More sharing options...
intoxopox Posted February 28, 2017 Author Share Posted February 28, 2017 Any thoughts on this request? I realize the implementation is different on graphics vs sprite-based, but it would be rad to have the method in Container for better polymorphism, and have it call the corrisponding implementation on graphic and sprite children. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 1, 2017 Share Posted March 1, 2017 By definition, if element has containsPoint(), its called when we determine if mouse clicked on that object. If you add it to the container, it'll be a disaster, because it will analyze container and its children two times. If there are three containers in eachother , that would be 8 times. There are other fields like that: filterArea, maskArea, e.t.c. , they don't care about children. So, if its implemented it will definitely have different name. Why do you even need that? Quote Link to comment Share on other sites More sharing options...
intoxopox Posted March 1, 2017 Author Share Posted March 1, 2017 I see. That makes sense. My particular use case is I have containers which have both sprite and graphic children. I was hoping to use something like containsPoint to see if mouse was still over any of the children. Further, I had abstracted this call in such a way that sometimes it would be called on one of the children and sometimes it would be called on the parent container. I can work around this ok, but just thought I had found a good reason to move the call to container and perhaps, in doing so, slightly improve the polymorphism. However, I see what you're saying. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 1, 2017 Share Posted March 1, 2017 Oh, you dont need that just make their parent interactive, and look in its "trackedPointers" field closely. I dont remember what exactly is there, just look at https://github.com/pixijs/pixi.js/blob/dev/src/interaction/InteractionManager.js and try to experiment with looking into that value. Quote Link to comment Share on other sites More sharing options...
intoxopox Posted March 1, 2017 Author Share Posted March 1, 2017 Ah... good looking out. I'll dig in later tonight. Thx! ClusterAtlas 1 Quote Link to comment Share on other sites More sharing options...
intoxopox Posted March 2, 2017 Author Share Posted March 2, 2017 Thanks again, ivan! That works great. Now I can test for pointer with just Object.keys(someContainer.trackedPointers).length. ivan.popelyshev 1 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.