cocos2d-x碰撞怎么检测碰撞的部位

2025-04-29 15:40:01
推荐回答(1个)
回答1:

在cocos2d-x中已经提供了矩形与矩形的碰撞检测以及点与矩形的碰撞检测,如下:

检测矩形与矩形碰撞的函数:

bool intersectsRect(const CCRect &rect) 使用方法: rect1.intersectsRect(rect2);
检测点与矩形碰撞的函数: bool containsPoint(const CCPoint &point) 使用方法: rect.containsPoint(point);
下面重点说矩形与圆形的碰撞检测: PS:先说一下cocos2d-x中的矩形Rect,Rect的构造有四个参数,x, y, width, height,