cocos2d-js 入门之碰撞

本文由qinning199原创,转载请注明:http://www.cocos2dx.net/post/223

1、cc.rectIntersectsRect(ra,rb) 判断两个矩形是否相交,若相交,返回true

用例:

var rectA = cc.rect(0,0,5,10);

var rectB = cc.rect(4,9,5,10);

var r = cc.rectIntersectsRect(rectA, rectB);

if(!r) throw "Fail rectIntersectsRect 1”;

2、cc.rectContainsPoint(rect,point) 判断某个矩形中是否包含某个点,若包含,返回true

3、cc.pointEqualToPoint(point1,point2) 判断两个点是否相等,相等返回true

4、cc.rectEqualToRect(rect1,rect2)判断两个矩形是否相等

5、cc._rectEqualToZero(rect)判断该矩形是否为0矩阵

6、cc.rectOverlapsRect(rectA,rectB)判断两个矩形是否部分重叠

7、cc.rectIntersection(rectA,rectB)返回两个矩形重叠部分

8、cc.rectUnion(rectA,rectB)返回包含这两个矩形的最小矩形

posted @ 2015-10-09 17:06  &&123  阅读(260)  评论(0编辑  收藏  举报