FlxG.overlap stopped working



  • Hiya!
    I use FlxG.overlap in my game to handle collisions between the player and stuff on the map. After updating flixel some time ago it stopped working.
    Code below is the collision check that currently does nothing at all.
    game.player and entities are FlxSprite derivatives. They are all in the same FlxGroup, but that doesn't matter as I already tried putting them in different groups.
    FlxG.collision doesn't work as well.

    So, did something change? I had no problems with this before.

    for(i in 0...entities.length){
    			if(FlxG.overlap(game.player, entities[i], onEntityCollision, FlxObject.separate)){
    				trace("0_o");
    			}
    		}
    

    My haxe version:
    flixel-addons: [2.0.0]
    flixel-tools: 1.1.2 [1.1.3]
    flixel: [4.0.1]
    hxcpp: [3.2.205]
    lime-samples: [2.6.0]
    lime: [2.9.1]
    openfl: [3.6.1]

    no collision ;_;

    cheers!



  • Hi rzuf,

    Try checking entities.length for 0, and checking game.player and every entities[i] for null.
    Try if(FlxG.overlap(game.player, entities[i], onEntityCollision) { - without 4th parameter.
    Also consider calling FlxG.overlap on the entire FlxGroup, rather than on every entity separately.



  • Hi, thanks for the reply!

    Try checking entities.length for 0, and checking game.player and every entities[i] for null.

    Checked already.

    Try if(FlxG.overlap(game.player, entities[i], onEntityCollision) { - without 4th parameter.

    Alas, nothing happened.

    Also consider calling FlxG.overlap on the entire FlxGroup, rather than on every entity separately.

    Huh. Now I can move this one tree around. Out of 8 sprites existing in the FlxGroup it's the only one that reacts in any way. Also, I can only push it left, right or down, but not up. And it stops after some pushing around.

    cleaning the forest

    Life is strange.

    I should also note, that the player's sprite position is changed just by simply modifying it's x and y coordinates, no playing with velocity or acceleration.



  • Did you set FlxG.worldBounds? I often forget and it leads to this.



  • Worked like a charm! Thanks a million!



  • @rzuf Haha I'm always on the lookout for that bug (not really a bug). It bit me really hard when I first encountered it.


Log in to reply
 

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