Cocos Creator API

0.7.1

Cocos Creator is a highly customizable game development tool that utilizes the power of cocos2d-x.

Rect

Extends ValueType
Module: cc

A 2D rectangle defined by x, y position and width, height.

see {% crosslink cc.Rect cc.rect %}

Properties

xMin Number

yMin Number

xMax Number

yMax Number

center Number

size Size

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

Methods

fromMinMax
(
  • v1
  • v2
)
Rect static

Creates a rectangle from two coordinate values.

name type description
v1 Vec2
v2 Vec2

returns:

type: Rect

contain
(
  • a
  • b
)
Number static

Checks if rect contains.

name type description
a Rect

Rect a

b Rect

Rect b

returns:

type: Number

The contains result, 1 is a contains b, -1 is b contains a, 0 is no contains.

clone ( ) Rect

returns:

type: Rect

equals
(
  • other
)
Boolean

name type description
other Rect

returns:

type: Boolean

lerp
(
  • to
  • ratio
  • [out ]
)
Rect

name type description
to Rect
ratio Number

the interpolation coefficient.

out optional Rect

optional, the receiving vector.

returns:

type: Rect

toString ( ) String

returns:

type: String

intersects
(
  • rect
)

name type description
rect Rect

contains
(
  • point
)

Returns true if the point inside this rectangle.

name type description
point Vec2

containsRect
(
  • rect
)

Returns true if the other rect totally inside this rectangle.

name type description
rect Rect

rect
(
  • [x =0]
  • [y =0]
  • [w =0]
  • [h =0]
)
Rect

The convenience method to create a new Rect.

name type description
x optional Number[] | Number 0
y optional Number 0
w optional Number 0
h optional Number 0

returns:

type: Rect

rectEqualToRect
(
  • rect1
  • rect2
)
Boolean

Check whether a rect's value equals to another.

name type description
rect1 Rect
rect2 Rect

returns:

type: Boolean

rectContainsRect
(
  • rect1
  • rect2
)
Boolean

Check whether the rect1 contains rect2.

name type description
rect1 Rect
rect2 Rect

returns:

type: Boolean

rectGetMaxX
(
  • rect
)
Number

Returns the rightmost x-value of a rect.

name type description
rect Rect

returns:

type: Number

The rightmost x value.

rectGetMidX
(
  • rect
)
Number

Return the midpoint x-value of a rect.

name type description
rect Rect

returns:

type: Number

The midpoint x value.

rectGetMinX
(
  • rect
)
Number

Returns the leftmost x-value of a rect.

name type description
rect Rect

returns:

type: Number

The leftmost x value.

rectGetMaxY
(
  • rect
)
Number

Return the topmost y-value of a rect.

name type description
rect Rect

returns:

type: Number

The topmost y value.

rectGetMidY
(
  • rect
)
Number

Return the midpoint y-value of `rect'.

name type description
rect Rect

returns:

type: Number

The midpoint y value.

rectGetMinY
(
  • rect
)
Number

Return the bottommost y-value of a rect.

name type description
rect Rect

returns:

type: Number

The bottommost y value.

rectContainsPoint
(
  • rect
  • point
)
Boolean

Check whether a rect contains a point.

name type description
rect Rect
point Vec2

returns:

type: Boolean

rectIntersectsRect
(
  • rectA
  • rectB
)
Boolean

Check whether a rect intersect with another.

name type description
rectA Rect
rectB Rect

returns:

type: Boolean

rectOverlapsRect
(
  • rectA
  • rectB
)
Boolean

Check whether a rect overlaps another.

name type description
rectA Rect
rectB Rect

returns:

type: Boolean

rectUnion
(
  • rectA
  • rectB
)
Rect

Returns the smallest rectangle that contains the two source rectangles.

name type description
rectA Rect
rectB Rect

returns:

type: Rect

rectUnion
(
  • rectA
  • rectB
)
Rect

Returns the overlapping portion of 2 rectangles.

name type description
rectA Rect
rectB Rect

returns:

type: Rect

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index