Array with multiple Objects with expire-timers fails

百般思念 提交于 2019-12-03 21:06:42

Have you tried keeping a dummy object (with all properties set to 0) in place of the particle element that you want to delete? Replace particles[i] = null with

particles[i] = {
    x: 0,
    y: 0,
    vx: 0,
    vy: 0,
    r: 0,
    angle: 0
};

Another solution might be keeping the particles[i] = null line, but modifying the code, where you apply the friction to the x and y, to check whether the object in question has those properties or not.

if(particles[i].hasOwnProperty('x') && particles[i].hasOwnProperty('y')){
//apply friction
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!