From bf06b4e949d3c526570855fddbdd19e3d2f1527f Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Thu, 5 Jun 2014 16:29:19 +0800 Subject: [PATCH] Issue #4986: May exceed the maximum margin of rect --- cocos2d/core/sprites/CCSprite.js | 8 ++++++-- cocos2d/core/sprites/CCSpriteFrame.js | 8 ++++++-- cocos2d/core/sprites/SpritesWebGL.js | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cocos2d/core/sprites/CCSprite.js b/cocos2d/core/sprites/CCSprite.js index ecf577bbc3..4ff76a7a3e 100644 --- a/cocos2d/core/sprites/CCSprite.js +++ b/cocos2d/core/sprites/CCSprite.js @@ -1309,8 +1309,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) { if(texture) { var _x = rect.x + rect.width, _y = rect.y + rect.height; - cc.assert(_x <= texture.width, cc._LogInfos.RectWidth, texture.url); - cc.assert(_y <= texture.height, cc._LogInfos.RectHeight, texture.url); + if(_x > texture.width){ + cc.error(cc._LogInfos.RectWidth, texture.url); + } + if(_y > texture.height){ + cc.error(cc._LogInfos.RectHeight, texture.url); + } } _t._originalTexture = texture; _t.texture = texture; diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js index 6653a712a4..d305631d92 100644 --- a/cocos2d/core/sprites/CCSpriteFrame.js +++ b/cocos2d/core/sprites/CCSpriteFrame.js @@ -364,8 +364,12 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{ _x = rect.x + rect.width; _y = rect.y + rect.height; } - cc.assert(_x <= texture.width, cc._LogInfos.RectWidth, texture.url); - cc.assert(_y <= texture.height, cc._LogInfos.RectHeight, texture.url); + if(_x > texture.width){ + cc.error(cc._LogInfos.RectWidth, texture.url); + } + if(_y > texture.height){ + cc.error(cc._LogInfos.RectHeight, texture.url); + } } this._rectInPixels = rect; diff --git a/cocos2d/core/sprites/SpritesWebGL.js b/cocos2d/core/sprites/SpritesWebGL.js index be3706a4ba..3f333fb003 100644 --- a/cocos2d/core/sprites/SpritesWebGL.js +++ b/cocos2d/core/sprites/SpritesWebGL.js @@ -184,8 +184,12 @@ cc._tmp.WebGLSprite = function () { _x = rect.x + rect.width; _y = rect.y + rect.height; } - cc.assert(_x <= texture.width, cc._LogInfos.RectWidth, texture.url); - cc.assert(_y <= texture.height, cc._LogInfos.RectHeight, texture.url); + if(_x > texture.width){ + cc.error(cc._LogInfos.RectWidth, texture.url); + } + if(_y > texture.height){ + cc.error(cc._LogInfos.RectHeight, texture.url); + } } _t.texture = texture;