Rect Class

Extends ValueType

Module: cc Parent Module: cc

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

Index

Properties
  • x Number
  • y Number
  • width Number
  • height Number
  • xMin Number TODO
  • yMin Number TODO
  • xMax Number TODO
  • yMax Number TODO
  • center Vec2 The position of the center of the rectangle.
  • origin Vec2 The X and Y position of the rectangle.
  • size Size Width and height of the rectangle.
Methods

Details

Properties

x
meta description
Type Number
Defined in cocos2d/core/value-types/CCRect.js:67
y
meta description
Type Number
Defined in cocos2d/core/value-types/CCRect.js:70
width
meta description
Type Number
Defined in cocos2d/core/value-types/CCRect.js:73
height
meta description
Type Number
Defined in cocos2d/core/value-types/CCRect.js:76
xMin

TODO

meta description
Type Number
Defined in cocos2d/core/value-types/CCRect.js:216
yMin

TODO

meta description
Type Number
Defined in cocos2d/core/value-types/CCRect.js:230
xMax

TODO

meta description
Type Number
Defined in cocos2d/core/value-types/CCRect.js:244
yMax

TODO

meta description
Type Number
Defined in cocos2d/core/value-types/CCRect.js:255
center

The position of the center of the rectangle.

meta description
Type Vec2
Defined in cocos2d/core/value-types/CCRect.js:266
origin

The X and Y position of the rectangle.

meta description
Type Vec2
Defined in cocos2d/core/value-types/CCRect.js:282
size

Width and height of the rectangle.

meta description
Type Size
Defined in cocos2d/core/value-types/CCRect.js:297

Methods

constructor

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

meta description
Defined in cocos2d/core/value-types/CCRect.js:39
Parameters
fromMinMax

Creates a rectangle from two coordinate values.

meta description
Returns Rect
Defined in cocos2d/core/value-types/CCRect.js:80
Parameters
Examples
cc.Rect.fromMinMax(cc.v2(10, 10), cc.v2(20, 20)); // Rect {x: 10, y: 10, width: 10, height: 10};
contain

Checks if rect contains.

meta description
Returns Number
Defined in cocos2d/core/value-types/CCRect.js:100
Parameters
Examples
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

TODO

meta description
Returns Rect
Defined in cocos2d/core/value-types/CCRect.js:139
Examples
var a = new cc.Rect(0, 0, 10, 10);
a.clone();// Rect {x: 0, y: 0, width: 10, height: 10}
equals

TODO

meta description
Returns Boolean
Defined in cocos2d/core/value-types/CCRect.js:152
Parameters
Examples
var a = new cc.Rect(0, 0, 10, 10);
var b = new cc.Rect(0, 0, 10, 10);
a.equals(b);// true;
lerp

TODO

meta description
Returns Rect
Defined in cocos2d/core/value-types/CCRect.js:171
Parameters
  • to Rect
  • ratio Number the interpolation coefficient.
  • out Rect optional, the receiving vector.
Examples
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

TODO

meta description
Returns String
Defined in cocos2d/core/value-types/CCRect.js:202
Examples
var a = new cc.Rect(0, 0, 10, 10);
a.toString();// "(0.00, 0.00, 10.00, 10.00)";
intersects

TODO

meta description
Defined in cocos2d/core/value-types/CCRect.js:312
Parameters
Examples
var a = new cc.Rect(0, 0, 10, 10);
var b = new cc.Rect(0, 0, 20, 20);
a.intersects(b);// true
contains

TODO

meta description
Defined in cocos2d/core/value-types/CCRect.js:327
Parameters
Examples
var a = new cc.Rect(0, 0, 10, 10);
var b = new cc.Vec2(0, 5);
a.contains(b);// true
containsRect

Returns true if the other rect totally inside this rectangle.

meta description
Defined in cocos2d/core/value-types/CCRect.js:346
Parameters
Examples
var a = new cc.Rect(0, 0, 20, 20);
var b = new cc.Rect(0, 0, 10, 10);
a.containsRect(b);// true

results matching ""

    No results matching ""