Cocos2d Chipmunk:自定义形状?
在我的应用程序中,我尝试使用 addPoly 来制作自定义形状,但它似乎根本不起作用! :(
我想我根本不明白如何使用它... :(
这是我创建一个简单正方形的尝试:
cpShape *square = [smgr addPolyAt:cpv(240,160) mass:100 rotation:0 numPoints:4 points:cpv(0, -10), cpv(10, 0), cpv(0, 10), cpv(-10, 0)];
我只是不知道如何使用它;你能帮我吗???
In my application i try to make custom shapes by using addPoly
, but it doesen't seem to work at all! :(
I think i don't understand how to use it at all... :(
Here's my attempt of creating a simple square:
cpShape *square = [smgr addPolyAt:cpv(240,160) mass:100 rotation:0 numPoints:4 points:cpv(0, -10), cpv(10, 0), cpv(0, 10), cpv(-10, 0)];
I just don't get how to use it; can you help me plz???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试以下几点:
cpv(0, 0)、cpv(10, 0)、cpv(10, -10)、cpv(0, -10)
请记住,您不能逆时针(始终是顺时针)创建多边形,并且不能仅以任何顺序添加点!顺便说一句,如果您没有与形状相关联的精灵,请使用
[self addChild:[smgr createDebugLayer]];
在模拟器中显示形状。问候亚历克斯...请随时提出任何后续问题
try these points:
cpv(0, 0), cpv(10, 0), cpv(10, -10), cpv(0, -10)
Remember you can't create the polygon counterclockwise (always clockwise) and you can't just add the points in any order! By the way if you don't have a sprite associated to the shape use
[self addChild:[smgr createDebugLayer]];
to show the shape in the simulator.Greetings Alex...feel free to ask any follow up questions