Hi,
Removing the tile after collision check is easy to do.
There is many way to do it, you can make the collision inactive and set the tile not visible, or just remove the tile if you don’t need it anymore
const isTileExplode = layer.getTileAt(tile.x, tile.y);
if (isTileExplode && isTileExplode.index !== -1)
{
layer.removeTileAt(tile.x, tile.y);
}
For the tile particle, you need a spritesheet of the tile, in multiple parts. But this add more graphics work.
Another solution, perhaps a bit overkill for your needs, i use it to explode my enemies in parts.
Use the tileset as an atlas, with every size divided by 2. For this, you need each tile as an image, and use a tool like Texture Packer to generate the json. With this json you can generate a new similar json with smaller parts. Here an example with sprites divided by 100.
private createExplodedSprites ()
{
const explodedFrames = [] as any[];
const atlasJson = require('../assets/gameSceneAssets/atlas.json');
// console.log(atlasJson);
atlasJson.textures[0].frames.forEach((frame) =>
{
for (let i = 0; i < 10; i += 1)
{
for (let j = 0; j < 10; j += 1)
{
const newFrame = {
filename: `${frame.filename}_explode_${i}${j}`,
frame: {
h: Math.round(frame.frame.h / 10),
w: Math.round(frame.frame.w / 10),
x: Math.round(frame.frame.x + (i * frame.frame.w / 10)),
y: Math.round(frame.frame.y + (j * frame.frame.h / 10)),
},
rotated: frame.frame.rotated,
sourceSize: {
h: Math.round(frame.frame.h / 10),
w: Math.round(frame.frame.w / 10)
},
spriteSourceSize: {
h: Math.round(frame.frame.h / 10),
w: Math.round(frame.frame.w / 10),
x: 0,
y: 0
},
trimmed: frame.frame.trimmed
};
explodedFrames.push(newFrame);
}
}
});
atlasJson.textures[0].frames.length = 0;
atlasJson.textures[0].frames = explodedFrames;
console.log(JSON.stringify(atlasJson));
}
You can now use this frames for particles