tilemap clear
This commit is contained in:
@@ -92,6 +92,6 @@ function pump() {
|
||||
$_.delay(pump, 1/240)
|
||||
}
|
||||
|
||||
pump()
|
||||
//pump()
|
||||
|
||||
return audio
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user