在网上看到的是CGRect的方法
CGRect projectileRect = CGRectMake(projectile.position.x , projectile.position.y , projectile.contentSize.width , projectile.contentSize.height ); CGRect targetRect = CGRectMake(target.position.x , target.position.y , target.contentSize.width, target.contentSize.height); if (CGRectIntersectsRect(projectileRect, targetRect)) { 碰撞了. }
自己用的CCRect的这个方法
CCRect hookstance=CCRectMake(hook->getPosition().x, hook->getPosition().y, hook->getContentSize().width, hook->getContentSize().height); CCRect shistance=CCRectMake(shi->getPosition().x,shi->getPosition().y, shi->getContentSize().width, shi->getContentSize().height); if (hookstance.intersectsRect(shistance)) { 碰撞了 }
版权属于:东哥笔记 - DongGe.org
本文链接:http://dongge.org/blog/33.html
本文采用知识共享署名4.0 国际许可协议进行许可。转载或大段使用必须添加本文链接,否则您将构成侵权!