CCRect

来源:互联网 发布:jquery 1.12.4.min.js 编辑:程序博客网 时间:2024/06/07 05:21
  1. class CC_DLL CCRect : public CCObject  
  2. {  
  3. public:  
  4.     //CCRect的原点  
  5.     CCPoint origin;  
  6.     //CCRect的大小  
  7.     CCSize  size;  
  8.   
  9. public:  
  10.     //构造函数  
  11.     CCRect();   
  12.     CCRect(float x, float y, float width, float height);      
  13.     CCRect(const CCRect& other);  
  14.     //意思是: = 操作就是从另一个CCRect的值赋给自己?  
  15.     CCRect& operator= (const CCRect& other);   
  16.     //设置其origin 以及 size  
  17.     void setRect(float x, float y, float width, float height);  
  18.     virtual CCObject* copyWithZone(CCZone* pZone);  
  19.     //获取X最小值  
  20.     float getMinX() const/// return the leftmost x-value of current rect  
  21.     //获取X中间值  
  22.     float getMidX() const/// return the midpoint x-value of current rect  
  23.     //获取X最大值  
  24.     float getMaxX() const/// return the rightmost x-value of current rect  
  25.     //获取Y最小值  
  26.     float getMinY() const/// return the bottommost y-value of current rect  
  27.     //获取Y中间值  
  28.     float getMidY() const/// return the midpoint y-value of current rect  
  29.     //获取最大Y值  
  30.     float getMaxY() const/// return the topmost y-value of current rect  
  31.     //比较两个CCRect是否吻合  
  32.     bool equals(const CCRect& rect) const;    
  33.     //是否包含某点,在边上也算的  
  34.     bool containsPoint(const CCPoint& point) const;  
  35.     //是否相交  
  36.     bool intersectsRect(const CCRect& rect) const;  
  37.       
  38. public:  
  39.     /** @deprecated use CCRect::equals(const CCRect&) instead, like r1.equals(r2) */  
  40.     //比较两个CCRect是否吻合  
  41.     CC_DEPRECATED_ATTRIBUTE static bool CCRectEqualToRect(const CCRect& rect1, const CCRect& rect2);  
  42.     /** @deprecated use CCRect::containsPoint(const CCPoint&) instead, like rect.containsPoint(point) */  
  43.     //CCRect是否包含某点  
  44.     CC_DEPRECATED_ATTRIBUTE static bool CCRectContainsPoint(const CCRect& rect, const CCPoint& point);  
  45.     /** @deprecated use CCRect::intersectsRect(const CCRect&) instead, like r1.intersectsRect(r2) */  
  46.     //两个CCRect是否相交  
  47.     CC_DEPRECATED_ATTRIBUTE static bool CCRectIntersectsRect(const CCRect& rectA, const CCRect& rectB);  
  48. };  
  49.   
  50. //定义CCRectMake方法,等同CCRect构造方法  
  51. #define CCRectMake(x, y, width, height) CCRect((float)(x), (float)(y), (float)(width), (float)(height))  
  52.   
  53. /* The "zero" rectangle -- equivalent to CCRectMake(0, 0, 0, 0). */   
  54. //定义CCRectZero,等同构造一个origin size都为0的CCRect  
  55. const CCRect CCRectZero = CCRectMake(0,0,0,0);