Query the world or QuadTree



  • Hello everyone,

    so far I am enjoying HF a lot, so first, thanks a lot to everyone working on the project!

    My question is, if it is possible to query the world or the QuadTree directly for a point (or cast a ray) and retrieve the object that is found (or multiple or none). My use case would be an instantaneous check whether something is on a given position. I could not find anything in the API docs, currently I am using an invisible Sprite for that and checking with FlxG.overlap for anything. However, not only does that feel like a strange indirection, overlap seems to be geared towards continuous checks in update(), not so much a single instantaneous one (which works better in a turn-based environment for example).

    I am envisioning something like that:

    
    function onMoveRight() {
        var foundObjects = FlxG.queryWorld(FlxPoint.get(player.x + 64, player.y), flxGroupOfInterestingObjects);
        if (foundObjects) {
           doSomethingWithObjects(foundObjects);
       }
    }
    
    

    Of course it is also very likely that I am missing something obvious. So how are you folks doing stuff like that?

    Thanks a lot in advance!


Log in to reply
 

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.