Skip to content

Commit 25b19a2

Browse files
committed
Merge pull request cocos2d#1899 from VisualSJ/develop-cocosudio
Issue #4986: May exceed the maximum margin of rect
2 parents 7667de0 + bf06b4e commit 25b19a2

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

cocos2d/core/sprites/CCSprite.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,8 +1309,12 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
13091309

13101310
if(texture) {
13111311
var _x = rect.x + rect.width, _y = rect.y + rect.height;
1312-
cc.assert(_x <= texture.width, cc._LogInfos.RectWidth, texture.url);
1313-
cc.assert(_y <= texture.height, cc._LogInfos.RectHeight, texture.url);
1312+
if(_x > texture.width){
1313+
cc.error(cc._LogInfos.RectWidth, texture.url);
1314+
}
1315+
if(_y > texture.height){
1316+
cc.error(cc._LogInfos.RectHeight, texture.url);
1317+
}
13141318
}
13151319
_t._originalTexture = texture;
13161320
_t.texture = texture;

cocos2d/core/sprites/CCSpriteFrame.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,12 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{
364364
_x = rect.x + rect.width;
365365
_y = rect.y + rect.height;
366366
}
367-
cc.assert(_x <= texture.width, cc._LogInfos.RectWidth, texture.url);
368-
cc.assert(_y <= texture.height, cc._LogInfos.RectHeight, texture.url);
367+
if(_x > texture.width){
368+
cc.error(cc._LogInfos.RectWidth, texture.url);
369+
}
370+
if(_y > texture.height){
371+
cc.error(cc._LogInfos.RectHeight, texture.url);
372+
}
369373
}
370374

371375
this._rectInPixels = rect;

cocos2d/core/sprites/SpritesWebGL.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,12 @@ cc._tmp.WebGLSprite = function () {
184184
_x = rect.x + rect.width;
185185
_y = rect.y + rect.height;
186186
}
187-
cc.assert(_x <= texture.width, cc._LogInfos.RectWidth, texture.url);
188-
cc.assert(_y <= texture.height, cc._LogInfos.RectHeight, texture.url);
187+
if(_x > texture.width){
188+
cc.error(cc._LogInfos.RectWidth, texture.url);
189+
}
190+
if(_y > texture.height){
191+
cc.error(cc._LogInfos.RectHeight, texture.url);
192+
}
189193
}
190194

191195
_t.texture = texture;

0 commit comments

Comments
 (0)