Reputation: 65
I have a level editing platformer game that I am making, which uses primarily phaser tilemaps for the level design. I load the level from an array, and I allow the player to edit the tilemap via map.putTileAt(type, x, y); This works well generally speaking, however when an animated sprite starts moving on the tilemap, it will sometimes get caught on the ground as if there was a wall in front of it. Any level data that I preload in the array never has this issue with the sprites. I assume that since I am adding each tile individually they each have a full collider with all four sides, compared to when the level is loaded and they don't have to use colliders in between the tiles. I am having a difficult time determining if this is my fault in the code, or if there is a way to refresh the colliders of the tilemap itself. Any help would be appreciated.
Upvotes: 0
Views: 204
Reputation: 14870
If you are using matter.js checkout this official example, it explains how to prevent/provoke this ghost collisions.
Here a snippet from the example, but you would have to adapt it to you array tilemap:
var rect = map.findObject('Collision', function (obj) { return obj.name === 'Stone Platform'; });
this.matter.add.rectangle(
rect.x + (rect.width / 2), rect.y + (rect.height / 2),
rect.width, rect.height,
{ isStatic: true }
);
If you are using arcade or other so please add some code to your question, since it is difficult to help without knowing real issue.
Upvotes: 0