I’m playing around with having hidden/revealed tiles on a map. I remembered that the pxt-tilemaps extension has a feature for covering a tile with another tile’s image, which seemed super handy.
However, it looks like there’s no way to remove a cover from a tile. (Maybe I’m just missing it!) I looked at the source and noticed the cover feature creates a sprite per covered tile with a special kind (SpriteKind._TileSprite). I tried using the array of sprites of kind (to select and destroy them), but that block didn’t include the _TileSprite kind…
Is there any way to destroy tile sprite covers once they’re created?
… also… after seeing the implementation that each tile is covered by a sprite, should I be concerned about the performance of games with moderately sized tilemaps where a high percentage of tiles start out covered? Should I look for an alternate approach to implementing a hidden/revealed tile mechanic?
Great question! We debated whether the special TileSprite kind should be visible to the user or not, and maybe incorrectly decided it shouldn’t be visible (because it is not obvious what it means). We might want to change that to enable situations like this.
If I recall correctly cover sprites are marked as “ghost” so they don’t affect physics checks which should mean you can have lots of them without impacting performance too much.
I thought perhaps the reload trick plus some extra tracking for which tiles were revealed could work, but then I ran into another limitation: currently cover is only provided for covering all tiles of type. It might be nice to also have a way to cover a specific tile at a location.