Refreshing local image file?

Hi,

I am having a problem with cocos2d-x not loading/refreshing a local image upon entering the scene for a second time but it works if i restart the app.

Basically I load Scene A which displays the screenshot correctly (one exists already otherwise there is a placeholder) and then i go into Scene B. Once finished in Scene B i take a screenshot and replace the original screenshot and return to Scene A, however when Scene A loads it displays the original screenshot and not the new screenshot that replaced it unless i restart the app then it loads the new screenshot.

i have tried to reload the texture in scene A using but this did not work

Director::getInstance()->getTextureCache()->reloadTexture(filepath->getCString());

i take a screenshot using

utils::captureScreen(CC_CALLBACK_2(MyLayer::afterCaptured, this),imageName->getCString());

Check the return code of the reloadTexture function, and make sure it returns true.
If it returns false, step into the function to see why it was not reloaded.

Are you storing/loading the screenshot into a sprite? Are you re-creating/re-initing the sprite, when switching back to scene A?

I figured it out. I was going back to Scene A too quick just had to delay by a little amount for it too work

1 Like

Good to hear it’s working :smile: