cocos2d-x CCSprite 更换图片 清空图片

一、更换图片spa

CCSprite * pImage = CCSprite::create("image.png");
CCTexture2D * text2d = CCTextureCache::sharedTextureCache()->addImage("other.png");
pImage->setTexture(text2d);
CCRect rect = CCRect(0, 0, text2d->getContentSize().width, text2d->getContentSize().height);
pImage->setTextureRect(rect);  // 要设置这个,图片才能保持other.png图片的大小,并且这句要在setTexture以后图片

二、清空图片get

pImage->setTexture(NULL);
pImage->setTextureRect(CCRect());it

相关文章
相关标签/搜索