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对象时