简体   繁体   中英

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.

Or another alternative: VertexHelper

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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