Files
tower/ts/simple_tile.ts

25 lines
643 B
TypeScript
Raw Normal View History

2021-05-11 02:57:17 +00:00
import { Tile } from './tile.js';
export class SimpleTile extends Tile {
animations: Map<string, [Keyframe[], object]>;
constructor(width: number, height: number, image_url: string, animations: Map<string, [Keyframe[], object]>) {
super(width, height);
this.elem.style.backgroundImage = `url('${encodeURIComponent(image_url)}')`;
this.elem.style.backgroundSize = 'cover';
this.animations = animations;
}
2021-05-11 03:12:32 +00:00
2021-05-11 05:17:16 +00:00
play(name: string): Animation | undefined {
2021-05-11 03:12:32 +00:00
const animation = this.animations.get(name);
if (animation) {
2021-05-11 05:17:16 +00:00
return this.elem.animate(...animation);
} else {
return undefined;
2021-05-11 03:12:32 +00:00
}
}
2021-05-11 02:57:17 +00:00
}