在cocos2d和chipmunk中从CGRect创建cpShape
我不知道如何创建适合 CGRect 的 cpShape。这是我到目前为止所尝试的,但没有成功:
CGPoint p1 = rect.origin;
CGPoint p2 = CGPointMake(rect.origin.x + rect.size.width, rect.origin.y);
CGPoint p3 = CGPointMake(rect.origin.x, rect.origin.y + rect.size.height);
CGPoint p4 = CGPointMake(rect.origin.x + rect.size.width, rect.origin.y + rect.size.height);
int num = 4;
CGPoint verts[] = {p2, p1, p3, p4};
shape = cpPolyShapeNew(body, num, verts, cpvzero);
我不明白为什么这不完全适合我的 CGRect ?
I can't figure out how to create a cpShape that will fit a CGRect. Here is what I tried so far, without any success :
CGPoint p1 = rect.origin;
CGPoint p2 = CGPointMake(rect.origin.x + rect.size.width, rect.origin.y);
CGPoint p3 = CGPointMake(rect.origin.x, rect.origin.y + rect.size.height);
CGPoint p4 = CGPointMake(rect.origin.x + rect.size.width, rect.origin.y + rect.size.height);
int num = 4;
CGPoint verts[] = {p2, p1, p3, p4};
shape = cpPolyShapeNew(body, num, verts, cpvzero);
I don't understand why this doesn't fit perfectly my CGRect ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的我明白了:
Ok I figured this out: