From 1dbb2ab17ae677c476effa6c10d190aa2dbf3d88 Mon Sep 17 00:00:00 2001 From: Jacky Date: Thu, 9 Jul 2015 09:58:14 +0800 Subject: [PATCH] refine setTexture. --- cocos/2d/CCSprite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 5482e8934c..befd6fe521 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");