tilemap clear

This commit is contained in:
2025-07-25 14:29:59 -05:00
parent f82d924577
commit fecc4b1285
2 changed files with 12 additions and 3 deletions

View File

@@ -92,6 +92,6 @@ function pump() {
$_.delay(pump, 1/240)
}
pump()
//pump()
return audio

View File

@@ -66,19 +66,28 @@ tilemap.prototype =
// Ensure array exists up to x
while (this.tiles.length <= x) this.tiles.push([]);
// Convert string to image object if needed
// Convert string to image object if needed, or handle null to remove tile
if (image && typeof image == 'string') {
var graphics = use('graphics');
image = graphics.texture(image);
}
// Note: if image is null, it will remove the tile
// Set the value
// Set the value (null removes the tile)
this.tiles[x][y] = image;
// Mark cache as dirty when tiles change
this._dirty = true;
},
clear() {
this.tiles = [];
this.offset_x = 0;
this.offset_y = 0;
this._geometry_cache = {};
this._dirty = true;
},
// Build cached geometry grouped by texture
_build_geometry_cache(pos = {x: 0, y: 0}) {
var geometry = use('geometry');