当我运行下面的代码时出现错误 - “无法读取未定义的属性'drawGame'”。为什么呢?
function Game() {
this.renderer = new Renderer(this.player);
this.startGame();
}
Game.prototype.startGame = function() {
this.renderer.drawGame(); //here error occurs
setTimeout(this.startGame, 20);
};
function Renderer(){
}
Renderer.prototype.drawGame = function() {
//function content
};