首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

对象中setInterval的有关问题

2013-08-10 
对象中setInterval的问题function A() {this.bBthis.b(1)this.afunction() {this.bulletnew Bullet()

对象中setInterval的问题


function A() {
this.b=B;
this.b(1);

this.a=function() {
this.bullet=new Bullet();
window.setInterval('this.bullet.run()', 100);
}
}


Bullet是一个类。
bullet是在B类中的,run方法没有问题,是测试过的。
问题是现在setInterval以后并不会执行。
我的意思就是这个程序这样的,请问应该怎么写?
[解决办法]

function A() {
this.b=B;
this.b(1);
this.a=function() {
this.bullet=new Bullet();
var t = this;
window.setInterval(function(){
t.bullet.run();
}, 100);
}
}

热点排行