1、更换图片

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之后

2、清空图片

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

相关文章:

  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
  • 2021-05-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
  • 2021-09-01
相关资源
相似解决方案