mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
fix CCRect api error
This commit is contained in:
@@ -105,9 +105,9 @@ Rect.fromMinMax = function (v1, v2) {
|
||||
* @param b {Rect} Rect b
|
||||
* @return {Number} The contains result, 1 is a contains b, -1 is b contains a, 0 is no contains.
|
||||
* @example
|
||||
* 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);
|
||||
* 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;
|
||||
@@ -138,7 +138,7 @@ var proto = Rect.prototype;
|
||||
* @method clone
|
||||
* @return {Rect}
|
||||
* @example
|
||||
* var a = new cc.rect(0, 0, 10, 10);
|
||||
* var a = new cc.Rect(0, 0, 10, 10);
|
||||
* a.clone();// Rect {x: 0, y: 0, width: 10, height: 10}
|
||||
*/
|
||||
proto.clone = function () {
|
||||
@@ -152,8 +152,8 @@ proto.clone = function () {
|
||||
* @param {Rect} other
|
||||
* @return {Boolean}
|
||||
* @example
|
||||
* var a = new cc.rect(0, 0, 10, 10);
|
||||
* var b = new cc.rect(0, 0, 10, 10);
|
||||
* var a = new cc.Rect(0, 0, 10, 10);
|
||||
* var b = new cc.Rect(0, 0, 10, 10);
|
||||
* a.equals(b);// true;
|
||||
*/
|
||||
proto.equals = function (other) {
|
||||
@@ -173,8 +173,8 @@ proto.equals = function (other) {
|
||||
* @param {Rect} [out] - optional, the receiving vector.
|
||||
* @return {Rect}
|
||||
* @example
|
||||
* var a = new cc.rect(0, 0, 10, 10);
|
||||
* var b = new cc.rect(50, 50, 100, 100);
|
||||
* 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);
|
||||
@@ -201,7 +201,7 @@ proto.lerp = function (to, ratio, out) {
|
||||
* @method toString
|
||||
* @return {String}
|
||||
* @example
|
||||
* var a = new cc.rect(0, 0, 10, 10);
|
||||
* var a = new cc.Rect(0, 0, 10, 10);
|
||||
* a.toString();// "(0.00, 0.00, 10.00, 10.00)";
|
||||
*/
|
||||
proto.toString = function () {
|
||||
@@ -312,8 +312,8 @@ JS.getset(proto, 'size',
|
||||
* @param {Rect} rect
|
||||
* @type {Boolean}
|
||||
* @example
|
||||
* var a = new cc.rect(0, 0, 10, 10);
|
||||
* var b = new cc.rect(0, 0, 20, 20);
|
||||
* var a = new cc.Rect(0, 0, 10, 10);
|
||||
* var b = new cc.Rect(0, 0, 20, 20);
|
||||
* a.intersects(b);// true
|
||||
*/
|
||||
proto.intersects = function (rect) {
|
||||
@@ -328,15 +328,15 @@ proto.intersects = function (rect) {
|
||||
* @param {Vec2} point
|
||||
* @type {Boolean}
|
||||
* @example
|
||||
* var a = new cc.rect(0, 0, 10, 10);
|
||||
* var b = new cc.v2(0, 5);
|
||||
* var a = new cc.Rect(0, 0, 10, 10);
|
||||
* var b = new cc.Vec2(0, 5);
|
||||
* a.contains(b);// true
|
||||
*/
|
||||
proto.contains = function (point) {
|
||||
return (this.x < point.x &&
|
||||
this.x + this.width > point.x &&
|
||||
this.y < point.y &&
|
||||
this.y + this.height > point.y);
|
||||
return (this.x <= point.x &&
|
||||
this.x + this.width >= point.x &&
|
||||
this.y <= point.y &&
|
||||
this.y + this.height >= point.y);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -346,15 +346,15 @@ proto.contains = function (point) {
|
||||
* @param {Rect} rect
|
||||
* @type {Boolean}
|
||||
* @example
|
||||
* var a = new cc.rect(0, 0, 10, 10);
|
||||
* var b = new cc.rect(0, 0, 20, 20);
|
||||
* var a = new cc.Rect(0, 0, 10, 10);
|
||||
* var b = new cc.Rect(0, 0, 20, 20);
|
||||
* a.containsRect(b);// true
|
||||
*/
|
||||
proto.containsRect = function (rect) {
|
||||
return (this.x < rect.x &&
|
||||
this.x + this.width > rect.x + rect.width &&
|
||||
this.y < rect.y &&
|
||||
this.y + this.height > rect.y + rect.height);
|
||||
return (this.x <= rect.x &&
|
||||
this.x + this.width >= rect.x + rect.width &&
|
||||
this.y <= rect.y &&
|
||||
this.y + this.height >= rect.y + rect.height);
|
||||
};
|
||||
|
||||
cc.Rect = Rect;
|
||||
@@ -376,7 +376,7 @@ cc.Rect = Rect;
|
||||
* @param {Number} [h=0]
|
||||
* @return {Rect}
|
||||
* @example
|
||||
* var a = new cc.rect(0 , 0, 10, 0);
|
||||
* var a = new cc.Rect(0 , 0, 10, 0);
|
||||
*/
|
||||
cc.rect = function rect (x, y, w, h) {
|
||||
return new Rect(x, y, w, h);
|
||||
@@ -393,10 +393,10 @@ cc.rect = function rect (x, y, w, h) {
|
||||
* @param {Rect} rect2
|
||||
* @return {Boolean}
|
||||
* @example
|
||||
* var a = new cc.rect(0, 0, 10, 10);
|
||||
* var b = new cc.rect(0, 0, 5, 5);
|
||||
* var a = new cc.Rect(0, 0, 10, 10);
|
||||
* var b = new cc.Rect(0, 0, 5, 5);
|
||||
* cc.rectEqualToRect(a, b); // false;
|
||||
* var c = new cc.rect(0, 0, 5, 5);
|
||||
* var c = new cc.Rect(0, 0, 5, 5);
|
||||
* cc.rectEqualToRect(b, c); // true;
|
||||
*/
|
||||
cc.rectEqualToRect = function (rect1, rect2) {
|
||||
@@ -417,8 +417,8 @@ cc._rectEqualToZero = function(rect){
|
||||
* @param {Rect} rect2
|
||||
* @return {Boolean}
|
||||
* @example
|
||||
* var a = new cc.rect(0, 0, 20, 20);
|
||||
* var b = new cc.rect(10, 10, 20, 20);
|
||||
* var a = new cc.Rect(0, 0, 20, 20);
|
||||
* var b = new cc.Rect(10, 10, 20, 20);
|
||||
* cc.rectContainsRect(a, b); // true;
|
||||
*/
|
||||
cc.rectContainsRect = function (rect1, rect2) {
|
||||
@@ -436,7 +436,7 @@ cc.rectContainsRect = function (rect1, rect2) {
|
||||
* @param {Rect} rect
|
||||
* @return {Number} The rightmost x value.
|
||||
* @example
|
||||
* var a = new cc.rect(10, 0, 20, 20);
|
||||
* var a = new cc.Rect(10, 0, 20, 20);
|
||||
* cc.rectGetMaxX(a); // 30;
|
||||
*/
|
||||
cc.rectGetMaxX = function (rect) {
|
||||
@@ -450,7 +450,7 @@ cc.rectGetMaxX = function (rect) {
|
||||
* @param {Rect} rect
|
||||
* @return {Number} The midpoint x value.
|
||||
* @example
|
||||
* var a = new cc.rect(10, 0, 20, 20);
|
||||
* var a = new cc.Rect(10, 0, 20, 20);
|
||||
* cc.rectGetMidX(a); // 20;
|
||||
*/
|
||||
cc.rectGetMidX = function (rect) {
|
||||
@@ -463,7 +463,7 @@ cc.rectGetMidX = function (rect) {
|
||||
* @param {Rect} rect
|
||||
* @return {Number} The leftmost x value.
|
||||
* @example
|
||||
* var a = new cc.rect(10, 0, 20, 20);
|
||||
* var a = new cc.Rect(10, 0, 20, 20);
|
||||
* cc.rectGetMinX(a); // 10;
|
||||
*/
|
||||
cc.rectGetMinX = function (rect) {
|
||||
@@ -477,7 +477,7 @@ cc.rectGetMinX = function (rect) {
|
||||
* @param {Rect} rect
|
||||
* @return {Number} The topmost y value.
|
||||
* @example
|
||||
* var a = new cc.rect(0, 10, 20, 20);
|
||||
* var a = new cc.Rect(0, 10, 20, 20);
|
||||
* cc.rectGetMaxY(a); // 30;
|
||||
*/
|
||||
cc.rectGetMaxY = function (rect) {
|
||||
@@ -491,7 +491,7 @@ cc.rectGetMaxY = function (rect) {
|
||||
* @param {Rect} rect
|
||||
* @return {Number} The midpoint y value.
|
||||
* @example
|
||||
* var a = new cc.rect(0, 10, 20, 20);
|
||||
* var a = new cc.Rect(0, 10, 20, 20);
|
||||
* cc.rectGetMidY(a); // 20;
|
||||
*/
|
||||
cc.rectGetMidY = function (rect) {
|
||||
@@ -505,7 +505,7 @@ cc.rectGetMidY = function (rect) {
|
||||
* @param {Rect} rect
|
||||
* @return {Number} The bottommost y value.
|
||||
* @example
|
||||
* var a = new cc.rect(0, 10, 20, 20);
|
||||
* var a = new cc.Rect(0, 10, 20, 20);
|
||||
* cc.rectGetMinY(a); // 10;
|
||||
*/
|
||||
cc.rectGetMinY = function (rect) {
|
||||
@@ -520,8 +520,8 @@ cc.rectGetMinY = function (rect) {
|
||||
* @param {Vec2} point
|
||||
* @return {Boolean}
|
||||
* @example
|
||||
* var a = new cc.rect(0, 10, 20, 20);
|
||||
* var b = cc.v2(0, 10, 10, 10);
|
||||
* var a = new cc.Rect(0, 10, 20, 20);
|
||||
* var b = new cc.Vec2(0, 10, 10, 10);
|
||||
* cc.rectContainsPoint(a, b); // true;
|
||||
*/
|
||||
cc.rectContainsPoint = function (rect, point) {
|
||||
@@ -537,8 +537,8 @@ cc.rectContainsPoint = function (rect, point) {
|
||||
* @param {Rect} rectB
|
||||
* @return {Boolean}
|
||||
* @example
|
||||
* var a = new cc.rect(0, 10, 20, 20);
|
||||
* var b = new cc.rect(0, 10, 10, 10);
|
||||
* var a = new cc.Rect(0, 10, 20, 20);
|
||||
* var b = new cc.Rect(0, 10, 10, 10);
|
||||
* cc.rectIntersectsRect(a, b); // true;
|
||||
*/
|
||||
cc.rectIntersectsRect = function (ra, rb) {
|
||||
@@ -557,8 +557,8 @@ cc.rectIntersectsRect = function (ra, rb) {
|
||||
* @param {Rect} rectB
|
||||
* @return {Boolean}
|
||||
* @example
|
||||
* var a = new cc.rect(0, 10, 20, 20);
|
||||
* var b = new cc.rect(0, 10, 10, 10);
|
||||
* var a = new cc.Rect(0, 10, 20, 20);
|
||||
* var b = new cc.Rect(0, 10, 10, 10);
|
||||
* cc.rectOverlapsRect(a, b); // true;
|
||||
*/
|
||||
cc.rectOverlapsRect = function (rectA, rectB) {
|
||||
@@ -576,8 +576,8 @@ cc.rectOverlapsRect = function (rectA, rectB) {
|
||||
* @param {Rect} rectB
|
||||
* @return {Rect}
|
||||
* @example
|
||||
* var a = new cc.rect(0, 10, 20, 20);
|
||||
* var b = new cc.rect(0, 10, 10, 10);
|
||||
* var a = new cc.Rect(0, 10, 20, 20);
|
||||
* var b = new cc.Rect(0, 10, 10, 10);
|
||||
* cc.rectUnion(a, b); // Rect {x: 0, y: 10, width: 20, height: 20};
|
||||
*/
|
||||
cc.rectUnion = function (rectA, rectB) {
|
||||
@@ -597,8 +597,8 @@ cc.rectUnion = function (rectA, rectB) {
|
||||
* @param {Rect} rectB
|
||||
* @return {Rect}
|
||||
* @example
|
||||
* var a = new cc.rect(0, 10, 20, 20);
|
||||
* var b = new cc.rect(0, 10, 10, 10);
|
||||
* var a = new cc.Rect(0, 10, 20, 20);
|
||||
* var b = new cc.Rect(0, 10, 10, 10);
|
||||
* cc.rectIntersection(a, b); // Rect {x: 0, y: 10, width: 10, height: 10};
|
||||
*/
|
||||
cc.rectIntersection = function (rectA, rectB) {
|
||||
|
||||
Reference in New Issue
Block a user