That’s unfortunate you can’t find any examples or tutorials. I know there are at least a few example of using a tilemap for digging. I’ve made some, dop2000 probably has too, and others as well.
Had a quick look at your example. Yes, it makes it visually look like there are holes but as you’ve noticed that’s not enough to change collisions. To erase you need to destroy or distort objects.
Here’s a mini tutorial on how to do digging with a tilemap.
1. Add a tilemap and fill it with tiles.
2. Add an event, on click, and add an action:
Tilemap: erase tile at self. PositionToTileX(mouse.x), self. PositionToTileY(mouse.y)
And that’s basically it. Reduce the tile size to make it less blocky.
If you want to erase a shape instead of one tile you have to explicitly erase the tiles one by one. If you try to use object overlaps tilemap to erase tiles it won’t work because it won’t tell you what tiles are overlapping.
To erase all the tiles overlapping an object you have to effectively check each tile one by one to see if they overlap. Construct doesn’t have a feature to do that so you’d need to do it indirectly.
Loop over all the tile location on the tilemap. For each location that has a tile you’d place a square sprite the same size as the tile, then use an overlap condition to see if that square sprite overlaps the shape you want to erase. If it does erase the tile the square is over.
To be faster you don’t have to loop over all the tiles. Just the ones around an object’s bounding box.
Pseudo code for how the event fit that would look is this. Sprite is the object you want to erase and square is a tile sized sprite with an origin at its top left.
For “x” from tilemap.positionToTileX(sprite.bboxLeft) to tilemap.positionToTileX(sprite.bboxRight)
For “y” from tilemap.positionToTileY(sprite.bboxTop) to tilemap.positionToTileY(sprite.bboxBottom)
tilemap: tile at loopindex(“x”),loopindex(“y”) <> -1
— square: set position to tilemap.tileToPositionX(loopindex(“x”)), tilemap.tileToPositionY(loopindex(“y”))
— square: overlaps sprite
— — tilemap: erase tile at loopindex(“x”),loopindex(“y”)
To texture the tilemap you’d probably just want to use a blend mode with a tiledbg.
Anyways if that’s clear as mud then you’ll have to just wait till an example can be made or someone helps you find the previously made examples.