Cocos2d-x  v4
Rect Class Reference

Rectangle area. More...

Public Member Functions

 Rect ()
 Constructor an empty Rect. More...
 
 Rect (float x, float y, float width, float height)
 Constructor a rect. More...
 
 Rect (const Vec2 &pos, const Size &dimension)
 Constructor a rect. More...
 
 Rect (const Rect &other)
 Copy constructor. More...
 
Rectoperator= (const Rect &other)
 @js NA @lua NA
 
void setRect (float x, float y, float width, float height)
 Set the x, y, width and height of Rect. More...
 
float getMinX () const
 Get the left of the rect. More...
 
float getMidX () const
 return the leftmost x-value of current rect More...
 
float getMaxX () const
 return the midpoint x-value of current rect More...
 
float getMinY () const
 return the rightmost x-value of current rect More...
 
float getMidY () const
 return the bottommost y-value of current rect More...
 
float getMaxY () const
 return the midpoint y-value of current rect More...
 
bool equals (const Rect &rect) const
 return the topmost y-value of current rect More...
 
bool containsPoint (const Vec2 &point) const
 Check if the points is contained in the rect. More...
 
bool intersectsRect (const Rect &rect) const
 Check the intersect status of two rects. More...
 
bool intersectsCircle (const Vec2 &center, float radius) const
 Check the intersect status of the rect and a circle. More...
 
Rect unionWithRect (const Rect &rect) const
 Get the min rect which can contain this and rect. More...
 
void merge (const Rect &rect)
 Compute the min rect which can contain this and rect, assign it to this.
 

Public Attributes

Vec2 origin
 Low left point of rect.
 
Size size
 Width and height of the rect.
 

Static Public Attributes

static const Rect ZERO
 An empty Rect.
 

Detailed Description

Rectangle area.

Constructor & Destructor Documentation

◆ Rect() [1/4]

Rect ( )

Constructor an empty Rect.

@js NA

◆ Rect() [2/4]

Rect ( float  x,
float  y,
float  width,
float  height 
)

Constructor a rect.

@js NA

◆ Rect() [3/4]

Rect ( const Vec2 pos,
const Size &  dimension 
)

Constructor a rect.

@js NA

◆ Rect() [4/4]

Rect ( const Rect other)

Copy constructor.

@js NA @lua NA

Member Function Documentation

◆ setRect()

void setRect ( float  x,
float  y,
float  width,
float  height 
)

Set the x, y, width and height of Rect.

@js NA @lua NA

◆ getMinX()

float getMinX ( ) const

Get the left of the rect.

@js NA

◆ getMidX()

float getMidX ( ) const

return the leftmost x-value of current rect

Get the X coordinate of center point. @js NA

◆ getMaxX()

float getMaxX ( ) const

return the midpoint x-value of current rect

Get the right of rect. @js NA

◆ getMinY()

float getMinY ( ) const

return the rightmost x-value of current rect

Get the bottom of rect. @js NA

◆ getMidY()

float getMidY ( ) const

return the bottommost y-value of current rect

Get the Y coordinate of center point. @js NA

◆ getMaxY()

float getMaxY ( ) const

return the midpoint y-value of current rect

Get top of rect. @js NA

◆ equals()

bool equals ( const Rect rect) const

return the topmost y-value of current rect

Compare two rects. @js NA

◆ containsPoint()

bool containsPoint ( const Vec2 point) const

Check if the points is contained in the rect.

@js NA

◆ intersectsRect()

bool intersectsRect ( const Rect rect) const

Check the intersect status of two rects.

@js NA

◆ intersectsCircle()

bool intersectsCircle ( const Vec2 center,
float  radius 
) const

Check the intersect status of the rect and a circle.

@js NA

◆ unionWithRect()

Rect unionWithRect ( const Rect rect) const

Get the min rect which can contain this and rect.

@js NA @lua NA


The documentation for this class was generated from the following file: