Jump to content

Getting all objects under point


Hachi
 Share

Recommended Posts

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 :).

Link to comment
Share on other sites

  • 2 weeks later...

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!

Link to comment
Share on other sites

  • 4 years later...

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 by ivan.popelyshev
Link to comment
Share on other sites

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.

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...