Adding Sprites to the body using Box2d

百般思念 提交于 2019-12-11 04:38:24

问题


I am trying to create an app like a CutTheRope. In My game,if i cut the rope,then i want to add sprites to the individual broken bodies.how to accomplish it.

Thanks....


回答1:


It totally depends how you are breaking your b2Body. I will answer the question according to the most feasible way to break body which is by creating multiple Fixtures on a body. When your body breaks, you destroy a fixture from your main body and recreate that fixture into a new b2Body. In box2d, the "Body", "Fixture" and "Joint" classes allows you to store "userData". So you store the sprite for broken bodies in their respective fixtures and when the body is broken then you can get the sprites for broken bodies from their respective fixtures.

I hope you understand.



来源:https://stackoverflow.com/questions/5752320/adding-sprites-to-the-body-using-box2d

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