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; }