function initImages(paths){
game.requiredImages = paths.length;
for(i in paths)
var img = new Image();
img.src = paths[i];
game.images[i] = img;
game.images[i].onload = function(){
game.doneImages++;
}
}
}
function checkImages(){
if(game.doneImages >= game.requiredImages){
init();
}else{
setTimeout(function(){
checkImages();
}, 1);
}
}
initImages(["player.png", "enemy.png", "bullet.png"]);
checkImages();
});
})();我有'未捕獲的SyntaxError:意外的記號功能',我不明白爲什麼?
第78行有一個問題=>函數initImages(路徑){ 我不知道什麼是錯誤的線索,我一直在按照教程和確切複製代碼;任何幫助將是偉大的
您似乎缺少部分代碼,該代碼也並非全部格式正確。 –
這個錯誤表明,在其他東西之後不會有'function'關鍵字。那麼,'function initImages'之前有什麼?此外,你可以嘗試像[JSHint](http://jshint.com/)這樣的linter。 –