摧毁碰撞精灵内部和周围的精灵
我需要帮助来销毁碰撞精灵内部和周围的精灵,即 2.5 厘米半径内的所有精灵都应该被销毁。这里的想法是我将从底部向从顶部落下的物体发射射弹。一旦发生碰撞,该半径周围的所有精灵也应该被摧毁。就像炸弹效果一样。我使用 box2d 进行碰撞,即接触侦听器。该怎么做呢?
请建议:-)
问候,
Karthik
I need help in destroying the sprites which are in and around the collided sprites ie in a radius of 2.5 cms all sprites should be destroyed. Idea here is i will be shooting a projectile from bottom to the objects falling from the top. Once collision happens all the sprites around that radius also should be destroyed. Like a Bomb Effect. I have used box2d for collision ie contact listener. How to go about doing that?
Please Suggest:-)
Regards,
Karthik
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
保存你的精灵数组,或者如果你使用的是batchNode,你可以这样做。
当碰撞发生时,检查你的精灵。检查他们的位置和爆炸中心的距离,如果在范围内就杀死他们。
例如,
方法“isInRangeOf:”将位于您的精灵子类中,
类似于..
希望有所帮助。
Hold an array of your sprites, or if you are using a batchNode you can do that.
When the collision happens, go through your sprites. Check the distance with their position and the explosion center and kill them if they are in range.
e.g.
the method 'isInRangeOf:' would be within your sprite subclass
Something like..
Hope that helps.