Get a tile to only collide with certain objects

  • I have a Flxtilemap with a certain tile that is a hole in the ground. I want this to behave like a wall to certain objects (the player) but I want certain other objects (bullets) to pass through it. What would be the best way to change the collision behavior for this tile based on what it is colliding with? I am thinking of using making a callback with setTileProperties but don't know how to actually change the collision behavior of a single tile.

    Relevant source code (specifically the setup method)

  • I suggest you to take a look at FlxG.overlap and FlxG.collide.

    You can group your sprites in FlxGroup if you have many (e.g. bullets, enemies) and then decide which group or sprites collide with the others. If you also create a method for the collision you could have a flag to activate or deactivate the collisions depending on your game logic.

    I recommend reading the book "discover haxeflixel", it is like a tutorial but explains everything very good with examples.

Log in to reply