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 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:66
y
meta description
Type Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:69
width
meta description
Type Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:72
height
meta description
Type Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:75
xMin

TODO

meta description
Type Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:215
yMin

TODO

meta description
Type Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:229
xMax

TODO

meta description
Type Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:243
yMax

TODO

meta description
Type Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:254
center

The position of the center of the rectangle.

meta description
Type Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:265
origin

The X and Y position of the rectangle.

meta description
Type Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:281
size

Width and height of the rectangle.

meta description
Type Size
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:296

Methods

constructor

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

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:38
Parameters
fromMinMax

Creates a rectangle from two coordinate values.

meta description
Returns Rect
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:79
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 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:99
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 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:138
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 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:151
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 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:170
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 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:201
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 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:311
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 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:326
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 https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:345
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 ""