@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
35 lines (28 loc) • 740 B
JavaScript
import View from "../View.js";
class GroupView extends View {
constructor() {
super();
const el = this.el = document.createElement("div");
el.classList.add("group");
this.children = [];
}
add(view) {
this.children.push(view);
this.el.appendChild(view.el);
return this;
}
remove(view) {
const indexOf = this.children.indexOf(view);
if (indexOf !== -1) {
this.children.splice(indexOf, 1);
this.el.removeChild(view.el);
}
return this;
}
update() {
this.children.forEach(function (c) {
c.update();
});
}
}
export default GroupView;