简体   繁体   English

Xcode中非矩形,闪亮图像的碰撞检测

[英]collision detection for non-rectangular, sparky images in Xcode

I'm making a maze-solving iphone app, and I was wondering if it is possible to make irregular-shaped images such as sparky ones, or the ones that are empty inside, etc. Could it be done by controlling the alpha value? 我正在制作一个解决迷宫问题的iPhone应用程序,我想知道是否可以制作不规则形状的图像,如闪亮的图像,或内部空的图像等。可以通过控制alpha值来完成吗? And if possible, how do we implement collision detection for such irregular images? 如果可能的话,我们如何实现这种不规则图像的碰撞检测? (I'm sure it's possible and I'm guessing it could be done by referring to alpha value of the pixel, but I just want to be concrete...) (我确信这是可能的,我猜它可以通过引用像素的alpha值来完成,但我只想具体......)

Also, for rectangular images so far, I have built my own basic collision detection function, which basically checks for axes values among all objects every frame, which I'm guessing could be a waste of computation and memory. 此外,对于目前为止的矩形图像,我已经建立了自己的基本碰撞检测功能,它基本上检查每帧中所有对象之间的轴值,我猜这可能是浪费计算和内存。 Does using chipmunk for collision detection make it more waste-free or efficient? 使用花栗鼠进行碰撞检测是否会使其更加无浪费或高效?

Please help me out! 请帮帮我! and Thanx in advance. 和Thanx提前。

Yes. 是。 Box2d and Chipmunk will allow you to set the shape of the sprite (circle, square, rect, etc) and define it and it will monitor for collisions. Box2d和Chipmunk将允许您设置精灵的形状(圆形,方形,矩形等)并定义它,它将监视碰撞。

Here is a great site for basic Cocos2d tutorials using Chipmunk and Box2d 这是使用Chipmunk和Box2d的基本Cocos2d教程的绝佳站点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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