A class is defined as follow:
export default class FishGame {
constructor(window) {
.......
this.window = window
......
}
gameloop() {
this.window.requestAnimationFrame(this.gameloop);
var now = Date.now();
this.deltaTime = now - this.lastTime;
this.lastTime = now;
....
}
}
you can see the function gameloop is a recursive call. I call this function in this way:
function game() {
let fishGame = new FishGame(this);
fishGame.gameloop();
}
while a exception is thrown, could someone tell me why this object is null?: