0
var spaceship = {
fps : 10,
speed : 1,
traveled : 0,
currency : 0,
initialize : function() {
this.update();
},
update : function() {
this.traveled += this.speed/this.fps;
setTimeout(this.update, 1000/this.fps);
this.render();
},
render : function() {
$("#spaceshipbg").attr("background-position", "0px "+this.traveled+"px");
}
};
$(document).ready(function() {
spaceship.initialize();
});
所以這是我的代碼,每當我加載的頁面中,我得到一個錯誤與線「this.render()」。我在這裏看不到問題,我可以從初始化函數成功調用this.update(),但是當我調用this.render()時,它說它是undefined「遺漏的類型錯誤:未定義是不是一個函數」調用函數withing對象時