Jump to content

Is there a more efficient way to get all sprites in an area?


Recommended Posts

I'm trying to create a drag selection tool.  At the moment, I''m simply drawing a graphic, keeping a rectangle in sync with that graphic, and checking each sprite to see if they intersect.  It works (well...after adjusting the library to allow intersections for negative widths and heights.  after testing, it will probably become a pull request.) and it might be a premature optimization, but I'm anticipating a higher number of sprites in my game meaning a ton of comparisons. It wouldn't exactly be n^2, just n.  But I feel as though I might be missing something in the api that might take care of this in a more optimized way.

I was originally hoping to take advantage of the quad tree with the new "retrieve" method, but it doesn't seem to return contained sprites (I'm assuming that it's only going to return sprites that are at the boarders).


Has anyone had to implement this control?  Was there a more efficient way to do this check?

Link to comment
Share on other sites


  • Recently Browsing   0 members

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