While I did figure something out, I still have a problem. The player tunnels through the terrain as well! This is what I'm doing. I create a map like in BSPMapGenerator. Then I sort of combine it with the SetTileProperties demo. I do it like this:
//When the flxtilemap is created from bspmapgenerator, i give it's tiles these properties
for (v in 1...16) map.setTileProperties(v, FlxObject.ANY, bombHit);
BombHit is just a rename of the function rightHit in SetTileProperties. I then set up everything else. For collisions, I go:
private function removeTile(Tile:FlxTile):Void
map.setTileByIndex(Tile.mapIndex, 0, true);
//Both here need to be FlxObject
private function bombHit(Tile:FlxObject, particle:FlxObject):Void
Again, the problem is tiles are set to 0 whenever the player object hits the tile map too. I've no idea how to fix that.
I need only the particles from the blue emitter to effect the tiles on the tile map and not the player object.
Setting height and offset.y without calling updateHitbox() or centerOffsets() should be enough.
Also I think recalculating the absolute height will be less error prone than changing it relative to the previous value.
If I build a tower, and that tower is destroyed by enemies, remove the tower. Now because it's a tower, I can place a second tower in the same spot of the tower that I lost.
The second function is for an experimental class called GateB. If I build a gateB, and that gateB is destroyed by enemies, it should be removed. The code is the same as the one for the tower. However, I can't build a new gateB in the same spot I lost a gateB.
EVEN THOUGH IT'S THE SAME CODE BUT WITH A DIFFERENT OBJECT.