options for scenelayer
This commit is contained in:
parent
96c73f49be
commit
d2ea90101b
@ -25,7 +25,7 @@ let layerHud = new SceneLayer('hud', [
|
||||
new Sprite('compass-arrow.png', 27, 21),
|
||||
]);
|
||||
|
||||
let layerInstances = new SceneLayer('Instances', [Player.rect]);
|
||||
let layerInstances = new SceneLayer('Instances', [Player.rect], { debug: true });
|
||||
|
||||
// init app
|
||||
let app = new App(document.querySelector('canvas'), 400, 400);
|
||||
|
@ -21,7 +21,7 @@ export class Scene {
|
||||
}
|
||||
|
||||
if (typeof item.draw == 'function') {
|
||||
item.draw(this.#context, true);
|
||||
item.draw(this.#context, layer.options.debug);
|
||||
} else {
|
||||
console.log(`⛔ Error display '${item.constructor.name}' object.`);
|
||||
}
|
||||
@ -47,9 +47,21 @@ export class Scene {
|
||||
export class SceneLayer {
|
||||
#objects;
|
||||
|
||||
constructor(name, objects = Array()) {
|
||||
constructor(
|
||||
name,
|
||||
objects = Array(),
|
||||
options = {
|
||||
debug: false,
|
||||
}
|
||||
) {
|
||||
// TODO: check types
|
||||
this.#objects = Array();
|
||||
this.options = options;
|
||||
|
||||
// check options || FIXIT:
|
||||
if (typeof this.options.debug === 'undefined') {
|
||||
this.options.debug = false;
|
||||
}
|
||||
|
||||
objects.forEach((object) => {
|
||||
this.#objects.push(object);
|
||||
|
Loading…
Reference in New Issue
Block a user