Files
tower/ts/layered_tile.ts

35 lines
869 B
TypeScript
Raw Permalink Normal View History

2021-05-17 04:26:18 +00:00
import { Mask } from './mask.js';
2021-05-11 02:57:17 +00:00
import { Tile } from './tile.js';
export class LayeredTile extends Tile {
2021-05-11 03:12:32 +00:00
tiles: Tile[];
2021-05-11 02:57:17 +00:00
2021-05-17 04:26:18 +00:00
constructor(width: number, height: number, masks: Map<string, Mask>, tiles: Tile[]) {
super(width, height, masks);
2021-05-11 03:12:32 +00:00
this.tiles = [];
2021-05-11 02:57:17 +00:00
this.elem.style.position = 'relative';
for (let i = 0; i < tiles.length; i++) {
const tile = tiles[i];
2021-05-11 03:12:32 +00:00
this.tiles.push(tile);
this.elem.appendChild(tile.elem);
tile.elem.style.width = '100%';
tile.elem.style.height = '100%';
tile.elem.style.position = 'absolute';
tile.elem.style.top = '0';
tile.elem.style.left = '0';
tile.elem.style.zIndex = `${i}`;
2021-05-11 03:12:32 +00:00
}
}
2021-05-11 05:17:16 +00:00
play(name: string): Animation | undefined {
let ret = undefined;
2021-05-11 03:12:32 +00:00
for (const tile of this.tiles) {
2021-05-11 05:17:16 +00:00
ret = tile.play(name) || ret;
2021-05-11 02:57:17 +00:00
}
2021-05-11 05:17:16 +00:00
return ret;
2021-05-11 02:57:17 +00:00
}
}