diff --git a/cocos2d/core/sprites/CCSpriteBatchNode.js b/cocos2d/core/sprites/CCSpriteBatchNode.js index 87233b5ee9..9f72438920 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNode.js +++ b/cocos2d/core/sprites/CCSpriteBatchNode.js @@ -561,14 +561,8 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{ addChild: function (child, zOrder, tag) { cc.assert(child != null, cc._LogInfos.CCSpriteBatchNode_addChild_3); - if (!(child instanceof cc.Sprite)) { - cc.log(cc._LogInfos.Sprite_addChild_4); - return; - } - if (child.texture != this._renderCmd.getTexture()) { - cc.log(cc._LogInfos.Sprite_addChild_5); + if(!this._renderCmd.isValidChild(child)) return; - } zOrder = (zOrder == null) ? child.zIndex : zOrder; tag = (tag == null) ? child.tag : tag; diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js index 511ba996f8..5a2f0844f5 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js @@ -36,6 +36,14 @@ proto.checkAtlasCapacity = function(){}; + proto.isValidChild = function(child){ + if (!(child instanceof cc.Sprite)) { + cc.log(cc._LogInfos.Sprite_addChild_4); + return false; + } + return true; + }; + proto.initWithTexture = function(texture, capacity){ this._originalTexture = texture; this._texture = texture; diff --git a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js index 1739228981..431e4a4f9a 100644 --- a/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js +++ b/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js @@ -34,6 +34,18 @@ var proto = cc.SpriteBatchNode.WebGLRenderCmd.prototype = Object.create(cc.Node.WebGLRenderCmd.prototype); proto.constructor = cc.SpriteBatchNode.WebGLRenderCmd; + proto.isValidChild = function(child){ + if (!(child instanceof cc.Sprite)) { + cc.log(cc._LogInfos.Sprite_addChild_4); + return false; + } + if (child.texture != this.getTexture()) { + cc.log(cc._LogInfos.Sprite_addChild_5); + return false; + } + return true; + }; + proto.rendering = function () { var node = this._node; if (this._textureAtlas.totalQuads === 0)