我是cocos2d-x的新手,正在实现自己的飞鸟。
现在,我正在使用碰撞检测,并且被卡住了。
我将down_pipe子画面和up_pipe子画面添加到父子画面管道,然后将父位移从右移到左。
但是当我检查碰撞时
if (bird->boundingBox().intersectsRect(pipes->boundingBox()))
没用
我这样尝试:
if (bird->boundingBox().intersectsRect(pipes->getChildByTag(DOWN_PIPE)->boundingBox()) || bird->boundingBox().intersectsRect(pipes->getChildByTag(UP_PIPE)->boundingBox()))
它仍然不起作用。
我该如何解决这个问题?有什么建议吗?
最佳答案
你试试这个
CCRect target = CCRectMake(pipes->getPosition().x - (pipes->getContentSize().width/2),pipes->getPosition().y - (pipes->getContentSize().height/2),pipes->getContentSize().width,pipes->getContentSize().height);
if(bird-> bounding Box()。intersects Rect(target))
关于c++ - 如何在cocos2d-x 2.2中检测三个 Sprite 的碰撞?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24387703/