Deleting and creating body in libGDX

前提是你 提交于 2019-12-06 23:41:05

I see only one error in you code, I am not sure that it causes the crash, but you should fix it in any way.

gameWorld.deletingList.removeIndex(i);

You must not remove items from array in the same time you looping thru the same array. This can result to unpredictable bugs, because every time you remove item, the array will change items order and decrease size. The solution is to create temporary array and loop thru it, so you will be able to remove items from original one.

Also where do you call your deleteObjects() ? You should call in render(), after world.step() and not in beginContact() or endContact().

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!