使用 Box2d 进行碰撞检测时需要帮助
在一些示例项目之后,我开始了我在 cocos 2d 和 box 2d 中的第一个游戏,其中物体从降落伞落下,你用弹弓杀死它们。现在我被一些事情困住了一段时间:
碰撞问题:
使用 Box 2d 我与物体发生了碰撞。然而,当我添加一个计数器来获取碰撞计数时,我不起作用。即使百分位移出屏幕,计数器也会增加。不知道如何摆脱这个问题。
我正在尝试让从上方掉落的精灵随机旋转,就像降落伞体验一样。现在,所有这些都以相同的角度旋转。
最后,当碰撞发生时,我需要摆脱周围的精灵。例如:当百分位数与下落物体碰撞时,半径为 2.5 厘米的其他精灵也应该消失。
我非常需要帮助和建议,因此所有 3 个问题@一次:-)。我已经提供了我的项目的链接,以便您可以查看源代码。急切地寻求你们的帮助!
下载源代码:
http://jumbofiles.com/6fn5mmpnq1q8/Karthik.zip.html
崭露头角的开发人员,
Karthik
After some sample projects, I have started with my first game in cocos 2d and box 2d where objects fall from a parachute and you kill them using slingshot. Now i'm stuck @ couple of things for a while:
Collision Issue:
Using Box 2d i have made collision with objects. However when i add a counter to get a count of my collision i doesn't work. Counter increases even though the percentile is moved out of the screen.Don't know how to get rid of this.
I'm trying to get random rotation to my sprites which fall from above, Like a parachute experience. Now all of then rotate @ a same angle.
Lastly i need to get rid of the surrounding sprites when collision happens. Ex: When the percentile collides with a falling object, in a radius of 2.5 cms the other sprites should also disappear.
I Badly need help and suggestions, hence all the 3 questions @ once :-). I have provided the link for my project so that you can look @ the source code. Desperately looking for your help guys!!!
Download Source Code:
http://jumbofiles.com/6fn5mmpnq1q8/Karthik.zip.html
Budding Developer,
Karthik
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您在这里有一个非常好的教程: http://www.raywenderlich.com/475/how-to-create-a-simple-breakout-game-with-box2d-and-cocos2d-tutorial-part-12
我认为可以解决您的问题:)
You have a pretty good tutorial here: http://www.raywenderlich.com/475/how-to-create-a-simple-breakout-game-with-box2d-and-cocos2d-tutorial-part-12
I think that one can solve your problems :)
您可以在这里获得适合您描述的特定要求的最佳教程......
其链接如下
http://www .raywenderlich.com/606/how-to-use-box2d-for-just-collision-detection-with-cocos2d-iphone
本教程由两部分组成,并简要描述了代码。描述了该代码,您可以从那里获得大量帮助。
You can get the best tutorial for the particular requirement you have described over here.....
The link for that is as follows
http://www.raywenderlich.com/606/how-to-use-box2d-for-just-collision-detection-with-cocos2d-iphone
The tutorial is of 2 parts and describes the code briefly.. The code of that is described and you can get good amount of help from there.
问题1 + 3:您需要阅读Mikael和Marine分享的链接
问题2:在cocos2d中,如果您想获得随机值,您可以使用支持函数(例如:rand(),random(),CCRANDOM_0_1().. ..)...我认为,您需要为对象设置旋转值。我不知道您的问题,您需要解释一下(链接是“由于不活动或 DMCA 未找到或删除/禁用文件”)
ques 1 + 3: you need read link which share by Mikael and Marine
ques 2: in cocos2d, if you want get random value, you can use support function (such as: rand(), random(), CCRANDOM_0_1() ....)... i think, you need set rotation value for object. i dont know your problem, you need explain it (link is "File Not Found or Deleted / Disabled due to inactivity or DMCA")