Hachi Posted August 24, 2015 Share Posted August 24, 2015 Hello, I have a turn-based strategy game project, which requires to get all the objects under one specific point. How is that possible in Pixi? Do I need to implement my own method for that?Before I have been using createjs a lot and it has the getObjectsUnderPoint method, which does this, but as I understand Pixi doesn't have the same kind of method (just for clarification, I mean anything along the lines what this easeljs method does: http://www.createjs.com/docs/easeljs/classes/SpriteContainer.html#method_getObjectsUnderPoint). I do not even need any InteractionManager to handle it for me I can implement the event detection, but I would just need to retrieve all the objects under the clicked / hovered point, when needed. Not only the top-most interactive object, but also the ones underneath it. I am in the middle of comparing switch to Pixi.js from easeljs, since the efficiency is crucial for me in this project and that little bit of optimized pixi-code is of interest to me . Quote Link to comment Share on other sites More sharing options...
xerver Posted August 24, 2015 Share Posted August 24, 2015 Easiest way would to be to create a structure that housed all those objects you want clickable and search it for your point. Quad/Oct-trees are pretty useful for this purpose. Quote Link to comment Share on other sites More sharing options...
Hachi Posted September 4, 2015 Author Share Posted September 4, 2015 After implementing quadtree, I still have the main problem to solve . Though I think I'm getting through, just didn't realize that I do actually have to implement my own detector (and it's not really the detectors I'm afraid of it's the worldTransforms - which quite frankly seem to be implemented to be used pretty easily) or use something from Interaction manager to do this (like seeing a possiblity if .processInteractive can manage detecting the elements inside the last quadtree section).But that quadtree suggestion was very useful for me, so thank you! Quote Link to comment Share on other sites More sharing options...
winterstein Posted April 24, 2020 Share Posted April 24, 2020 Does Pixi contain an implementation of quadtree? (better to reuse code when you can) Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 25, 2020 Share Posted April 25, 2020 (edited) PixiJS is not a framework, nor is it an game engine. The fact that there's no quadtree in plugins means that everyone who used quadtree with pixi didnt take their time to make a plugin and documentation for it - its simple as that Wanna be that hero? Pixi does have a few serious algorithms but they are all webgl-rendering related, not stage-related, that's why its possible to use it in custom engines with their custom maths and awesome algorithms. Edited April 25, 2020 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 25, 2020 Share Posted April 25, 2020 InteractionManager ( https://github.com/pixijs/pixi.js/blob/dev/packages/interaction/src/InteractionManager.js ) is a event-heavy thing, and TreeSearch is separated ( https://github.com/pixijs/pixi.js/blob/dev/packages/interaction/src/TreeSearch.js ) , and you can modify it to add quad-tree. "renderer.plugins.interaction.treeSearch = ..." Currently treesearch uses containsPoint() function of element. quad-tree will require to calculate getBounds() on whole tree every frame and check if something did change - which is actually whole scan all over again. You have to add your own triggers for modifying quadtree info otherwise it will be very slow. And that's the real reason that we dont have quadtree - too many "shackles" for objects. Every contributor who modify displayobject/container/sprite/mesh would have to add extra optimizations there to keep pixi from becoming slow because we want to use extra optimization in interaction for big scenes that require it. Its possible to add in a specific game with specific stage behaviours but not in the rendering lib. 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.