How to swap the sprite in the CCSprite object in Cocos2d-X
问题 I have an object that inherited from CCSprite. I want from inside this object to change the image. How do I change the image (sprite) without creating a new CCSprite object in Cocos2d-X? Thanks, Adrian. 回答1: mySprite->setTexture(CCTextureCache::sharedTextureCache()->addImage("newImage.png")); No need to alter your custom class.. Hope this helps.. :) 回答2: Works for me: mySprite->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("frame_name")); Before you need to