Jump to content

Dynamic layer overlapping


zetsubou
 Share

Recommended Posts

Hi!
I have a dynamic layer consisting of coins, that player is supposed to collect throughout the whole game. My goal is just remove tile on overlap with a player. I tried a couple of solutions I found. These are:
 

const groundTileset = map.addTilesetImage("tile1", "ground_objects");
const batteries = map.createDynamicLayer("battery", groundTileset, 0, 0);

// the first solution i tried
batteries.setTileIndexCallback(7, playerAbsorbsBattery, this);

// and the second one 
this.physics.add.overlap(player, batteries, playerAbsorbsBattery, null, this);

Using a second one causes collision with everything i have on map, so its always invoked until i remove all tiles(so I need to somehow specify (objects || tiles || sprites), thats it collides with?)
And i tried similar solution on labs.phaser - didn't help.

Link to comment
Share on other sites

Spent 4 hours searching for a solution and in a complete desperation decided to create a topic to ask for help. And then, in 5 minutes I just solved it.
 

map.setTileIndexCallback(7, playerAbsorbsBattery, this);

Thought i checked this one, but apparently I had not.
Guess this topic might be deleted.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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