feat(#8): improve debug
This commit is contained in:
parent
4e2905cf96
commit
731a32303a
8 changed files with 84 additions and 88 deletions
|
@ -1,17 +1,19 @@
|
|||
export class GameObject {
|
||||
/**
|
||||
* Initializes a new instance of the GameObject class.
|
||||
*
|
||||
* @param {Object} options - An object containing the initial properties of the game object.
|
||||
* @param {number} [options.x=0] - The initial x-coordinate of the game object.
|
||||
* @param {number} [options.y=0] - The initial y-coordinate of the game object.
|
||||
* @param {GameObject[]} [options.gameObjects=[]] - An array of child game objects.
|
||||
*/
|
||||
constructor(options = {}) {
|
||||
const { x = 0, y = 0, gameObjects = [] } = options;
|
||||
const {
|
||||
x = 0,
|
||||
y = 0,
|
||||
width = 0,
|
||||
height = 0,
|
||||
debug = false,
|
||||
gameObjects = [],
|
||||
} = options;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.gameObjects = gameObjects;
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
async load() {
|
||||
|
@ -47,6 +49,9 @@ export class GameObject {
|
|||
}
|
||||
|
||||
onMouseClick(elementId) {
|
||||
if (elementId === "debug") {
|
||||
this.debug = !this.debug;
|
||||
}
|
||||
this.gameObjects.forEach((item) => {
|
||||
item.onMouseClick(elementId);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue