在Box2D(libgdx)中移除一个物体会立即崩溃游戏

问题描述:

这不是在我意识到的world.step()方法期间完成的,而我在互联网上发现的所有内容都是关于人们在碰撞时进行的。在Box2D(libgdx)中移除一个物体会立即崩溃游戏

我基本上就是这样,所以如果我按空间的一段绳子会被破坏。它的毁坏很严重,但是游戏之后会立即崩溃。这就是我得到:

This application has requested the Runtime to terminate it in an unusual way. 
Please contact the application's support team for more information. 
AL lib: (EE) alc_cleanup: 1 device not closed 
Assertion failed! 

Program: C:\Program Files\Java\jdk1.8.0_65\bin\java.exe 

File: ./Box2D/Dynamics/b2Island.h, Line 54 

Expression: m_bodyCount < m_bodyCapacity 

代码:

的游戏画面 http://pastebin.com/x1x62axh

http://pastebin.com/SgtsMKKQ

我想,当你按下它破坏得太快空间,当没有更多的绳索代码导致错误。

world.destroyBody(segments.get(segments.size()-1)); 

检查segments.size()> 0当你摧毁。

我也建议

Gdx.input.isKeyJustPressed(int key) 

,而不是

Gdx.input.isKeyPressed(int key) 
+0

哇,正确的金钱。我这么新,以至于我永远无法想象自己,谢谢! –