我试图遍历所有使用我的课程之一的变量,例如let Player = new GameObject("Player", 0, 0, 5, 5);
。
我已经尝试过了
class GameObject {
constructor(name, posX, posY, sizeX, sizeY) {
this.name = name;
this.posX = posX;
this.posY = posY;
this.sizeX = sizeX;
this.sizeY = sizeY;
}
}
let Player = new GameObject("Player", 0, 0, 5, 5);
let Player2 = new GameObject("Player2", 0, 0, 5, 5);
for (let f in window) {
if (window[f] instanceof GameObject) {
console.log("founded" + f);
}
}
但是只有我得到的是这个警告:
VM147:15 [Deprecation] 'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.
我什至尝试了Google的问题,但没有发现有用的东西。
class GameObject {
constructor(name, posX, posY, sizeX, sizeY) {
this.name = name;
this.posX = posX;
this.posY = posY;
this.sizeX = sizeX;
this.sizeY = sizeY;
}
}
let Player = new GameObject("Player", 0, 0, 5, 5);
let Player2 = new GameObject("Player2", 0, 0, 5, 5);
function update() {
for (let f in window) {
if (window[f] instanceof GameObject) {
console.log("founded" + f);
}
}
requestAnimationFrame(update);
}
update();
我希望输出Player1, Player2
,但实际输出是VM147:15 [Deprecation] 'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.