From faf22b30d675adf9187d7721fecaece46a8eb346 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Wed, 23 Dec 2015 14:44:09 +0800 Subject: [PATCH] Vec2, Rect and Size could be inited by null --- cocos2d/core/value-types/CCRect.js | 2 +- cocos2d/core/value-types/CCSize.js | 2 +- cocos2d/core/value-types/CCVec2.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/value-types/CCRect.js b/cocos2d/core/value-types/CCRect.js index 9089b05f97..57921bc506 100644 --- a/cocos2d/core/value-types/CCRect.js +++ b/cocos2d/core/value-types/CCRect.js @@ -15,7 +15,7 @@ var JS = require('../platform/js'); * @param {Number} [h=0] */ function Rect (x, y, w, h) { - if (typeof x === 'object') { + if (x && typeof x === 'object') { y = x.y; w = x.width; h = x.height; diff --git a/cocos2d/core/value-types/CCSize.js b/cocos2d/core/value-types/CCSize.js index a46d410a78..c93c428150 100644 --- a/cocos2d/core/value-types/CCSize.js +++ b/cocos2d/core/value-types/CCSize.js @@ -10,7 +10,7 @@ var JS = require('../platform/js'); * @see cc.size */ function Size (width, height) { - if (typeof width === 'object') { + if (width && typeof width === 'object') { height = width.height; width = width.width; } diff --git a/cocos2d/core/value-types/CCVec2.js b/cocos2d/core/value-types/CCVec2.js index ea86de0149..14749311f5 100644 --- a/cocos2d/core/value-types/CCVec2.js +++ b/cocos2d/core/value-types/CCVec2.js @@ -18,7 +18,7 @@ var FireClass = require('../platform/CCClass'); * @param {number} [y=0] */ function Vec2 (x, y) { - if (typeof x === 'object') { + if (x && typeof x === 'object') { y = x.y; x = x.x; }