蜂は楽しいゲームを作り始めます。問題は、ゲームオブジェクトに新しいプレーヤーを作るときに、更新関数では定義されていないが、作成関数で定義されているということです。ここでプレイヤーは更新時に定義されていませんが、作成時には定義されていません
Game.prototype = {
create: function() {
this.player = new Player(this.ctx, this.canvas);
this.player.create();
console.log(this.player); // shows the player in console
},
update: function() {
console.log(this.player); //undefined
this.player.update();
}
};
私は
function startGame(){
var fps = 1;
var game = new Game();
game.create();
setInterval(game.update, 1000/fps);
}
エラー - >キャッチされない例外TypeError私のゲームを起動する方法です:あなたは
多分、 'setInterval(function(){game.update()}、1000/fps)' – CollinD
を試してみてください。 – iWillBeMaster