Cocos2d - 旋转雪碧的碰撞检测 [英] Cocos2d - Collision Detection of Rotated Sprite

查看:192
本文介绍了Cocos2d - 旋转雪碧的碰撞检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试检测两个sprite之间的碰撞。

I try to detect collision between two sprite.

if(CGRectIntersectsRect([SpriteA BoundingBox], [SpriteB boundingBox]))

但是当我旋转任何sprite碰撞检测不是完美的..
使用像素完美碰撞,但我不知道它。
请任何人帮助我如何检测冲突,给我任何代码块。

But when i Rotate any sprite than collision detection is not perfect.. I know to use pixel perfect Collision but i have no idea about it. Please anyone help me for how to detect collision, Give me any block of code if any.

推荐答案


  1. 对你的sprite使用box2D体。示例:点击这里

  2. 使用CGMutablePathRef,并使用CGPathContainsPoint(),而不是CGRectIntersectsRect。
    示例:点击这里

  1. Use box2D body for your sprite. Example: CLICK HERE
  2. Use CGMutablePathRef, and use CGPathContainsPoint() instead of CGRectIntersectsRect. Example: CLICK HERE

这篇关于Cocos2d - 旋转雪碧的碰撞检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆