Cocos Creator API

1.3.0

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

Rect

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

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

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

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

x optional Number 0
y optional Number 0
w optional Number 0
h optional Number 0

:

: Rect

fromMinMax
(
  • v1
  • v2
)
Rect static

Creates a rectangle from two coordinate values.

v1 Vec2
v2 Vec2

:

: Rect

:

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.

a Rect

Rect a

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

Rect b

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

:

: Number

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

:

var a = new cc.rect(0, 0, 10, 10);
var b = new cc.rect(5, 5, 5, 5);
var c = new cc.rect(20, 20, 10, 10);
cc.Rect.contain(a, b); //  1;
cc.Rect.contain(b, a); // -1;
cc.Rect.contain(a, c); //  0;

clone ( ) Rect

TODO

:

: Rect

:

var a = new cc.rect(0, 0, 10, 10);
a.clone();// Rect {x: 0, y: 0, width: 10, height: 10}

equals
(
  • other
)
Boolean

TODO

other Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

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

:

:

var a = new cc.rect(0, 0, 10, 10);
var b = new cc.rect(0, 0, 10, 10);
a.equals(b);// true;

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

TODO

to Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

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

the interpolation coefficient.

out optional Rect

optional, the receiving vector.

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

:

: Rect

:

var a = new cc.rect(0, 0, 10, 10);
var b = new cc.rect(50, 50, 100, 100);
update (dt) {
   // method 1;
   var c = a.lerp(b, dt * 0.1);
   // method 2;
   a.lerp(b, dt * 0.1, c);
}

toString ( ) String

TODO

:

: String

:

var a = new cc.rect(0, 0, 10, 10);
a.toString();// "(0.00, 0.00, 10.00, 10.00)";

intersects
(
  • rect
)

TODO

rect Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

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

:

var a = new cc.rect(0, 0, 10, 10);
var b = new cc.rect(0, 0, 20, 20);
a.intersects(b);// true

contains
(
  • point
)

TODO

point Vec2

:

var a = new cc.rect(0, 0, 10, 10);
var b = new cc.v2(0, 5);
a.contains(b);// true

containsRect
(
  • rect
)

Returns true if the other rect totally inside this rectangle.

rect Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

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

:

var a = new cc.rect(0, 0, 10, 10);
var b = new cc.rect(0, 0, 20, 20);
a.containsRect(b);// true

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