diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 30b153a40c..3686d3bf08 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -343,7 +343,7 @@ void Sprite::setTexture(const std::string &filename) void Sprite::setTexture(Texture2D *texture) { // If batchnode, then texture id should be the same - CCASSERT(! _batchNode || texture->getName() == _batchNode->getTexture()->getName(), "CCSprite: Batched sprites should use the same texture as the batchnode"); + CCASSERT(! _batchNode || (texture && texture->getName() == _batchNode->getTexture()->getName()), "CCSprite: Batched sprites should use the same texture as the batchnode"); // accept texture==nil as argument CCASSERT( !texture || dynamic_cast(texture), "setTexture expects a Texture2D. Invalid argument");