我正在使用EaselJS和Box2DWeb创建一个箭头射击游戏。每当箭头与另一个身体碰撞时,它就会死亡,我称之为这个功能:
if(body.dead){
removeActor(body.GetUserData()) //the user data is the actor object (sprite) of the arrow
world.DestroyBody(body);
delete body;
bodies.splice(i, 1);
i--;
}
和removeActor函数:
// remove actor and it's skin object
var removeActor = function(actor) {
if(actor){
stage.removeChild(actor.skin);
actors.splice(actors.indexOf(actor),1);
delete actor;
}
}
我尝试不断创建箭头并检查内存是否已被释放(使用chrome任务管理器),但仅使用的内存增加。有没有办法让我从内存中完全删除这些对象?