Xcode 中非矩形、闪光图像的碰撞检测
我正在制作一个解决迷宫的 iPhone 应用程序, 我想知道是否可以制作不规则形状的图像,例如闪闪发光的图像,或内部空的图像等。 可以通过控制alpha值来实现吗? 如果可能的话,我们如何对这种不规则图像实现碰撞检测? (我确信这是可能的,并且我猜想可以通过引用像素的 alpha 值来完成,但我只是想具体一点......)
另外,对于到目前为止的矩形图像,我已经构建了自己的基本图像碰撞检测功能,它基本上检查每帧所有对象之间的轴值,我猜这可能会浪费计算和内存。使用花栗鼠进行碰撞检测是否会更无浪费或更高效?
请帮帮我! 提前致谢。
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?
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...)
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的。 Box2d 和 Chipmunk 将允许您设置精灵的形状(圆形、方形、矩形等)并定义它,并且它将监视碰撞。
这是一个很棒的网站使用 Chipmunk 和 Box2d 的基本 Cocos2d 教程
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.
Here is a great site for basic Cocos2d tutorials using Chipmunk and Box2d