I'm trying to make a physics sprite collide with a Dynamic TileMap but I cannot get it collide.
There is a github with my code here: https://github.com/nahkranoth/FactorySimulator/tree/tilemap-creator
I took this as an example: https://labs.phaser.io/edit.html?src=src\game objects\tilemap\collision\tile callbacks.js
I setup the tilemap like this (in tileMap.js) note that tileset is a tileset I created by generating a texture out of a graphic but I don't think that should matter:
this.layer = this.map.createDynamicLayer(0, tileset, 0, 0);
this.layer.setCollision(1);
Then in game.js I make a physics sprite and add it to the collider:
this.sprite1 = this.physics.add.sprite(120, 420, "tiles");
this.tilemap.layer.setTileIndexCallback(1, this.hitCoin, this);
this.physics.add.collider(this.sprite1, this.tilemap.layer);
>> The callback hitCoin is called when the sprite is colliding with a tile, but the sprite wont stop on a tile. While I took this from earlier code and it did stop.
I know this explanation is missing a lot of details that matter - but if you look at those two files in the github project you should be able to find out those details.
edit:
Does the fact that I set the index of the tiles like tile.index = 1? IS there another method I'm not aware of?