简体   繁体   English

创建实体-Cocos2d / Box2d

[英]Creating a Body - Cocos2d/Box2d

I have a ball and another sprite. 我有一个球和另一个精灵。 When the ball collides with the sprite it simulates falling. 当球与精灵碰撞时,它会模拟下落。

My only problem is the other sprite is just on big image and the ball is on top of it, but there are spaces on the sprite and a lot of corners. 我唯一的问题是另一个精灵只在大图片上,球在它上面,但是精灵上有很多空间,并且有很多角落。 I need to determine if the sprite has touch one of the corners. 我需要确定精灵是否触碰到角落之一。 I know this is hard to understand. 我知道这很难理解。

So, my question is, is it possible to make a body without 所以,我的问题是,有没有可能使一个身体

b2PolygonShape blockShape;

and

blockShapeDef.shape = &blockShape;

OR 要么

is there an alternative I can use? 有没有我可以使用的替代方法? I cannot set the image as a box and it would take way to long to set edges because there are so many corners. 我无法将图像设置为盒子,并且设置边缘会花费很长时间,因为有很多角。

I have already set up the collision detection. 我已经设置了碰撞检测。 I really need help with this. 我真的需要帮助。

Thanks! 谢谢!

If you want it to react properly, you have to make a polygon using every single corner coordinate. 如果希望它正确反应,则必须使用每个角点坐标制作一个多边形。

But don't be lazy about it. 但是不要偷懒。 You can use SpriteHelper for creating *b2PolygonShape*s out of your sprites. 您可以使用SpriteHelper从子画面中创建* b2PolygonShape * s。

Or another alternative: VertexHelper 或另一种选择: VertexHelper

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM