Cocos Creator API

1.4.x

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.

Properties

xMin Number

TODO

yMin Number

TODO

xMax Number

TODO

yMax Number

TODO

center Number

TODO

size Size

TODO

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

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

Constructor of cc.Rect class. see cc.rect for convenience method.

name type description
x optional Number 0
y optional Number 0
w optional Number 0
h optional Number 0

returns:

type: Rect

fromMinMax
(
  • v1
  • v2
)
Rect static

Creates a rectangle from two coordinate values.

name type description
v1 Vec2
v2 Vec2

returns:

type: Rect

examples:

cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10};

contain
(
  • a
  • b
)
Number static

Checks if rect contains.

name type description
a Rect

Rect a

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0