Sprite->SetTexture failed after pause.

Sprite->SetTexture failed after pause.
0.0 0



I’ve got a problem on setTexture because when i put the application in background and resume it the texture becomes lines in place of staying like the original sprites.
Have you any ideas about how to fix it?


Thank you, Have a good day.

img_1.png (104.6 KB)

img_2.png (87.8 KB)


You generated texture by yourself, so you should reload them as engine did after OpenGL context lost.
You can refer CCTextureCache::addImage(), which caches file path, and HelloWorld/android/jni/helloworld/main.cpp, which reloads texture.


Thank you for your answer :smiley:



I tried to use your tips, but i continue to have this error again.
The thing is in the main i’m using reloadAllTexture, and at the construction of my sprite i’m using CCTextureCache::addImage and setTexture on the sprite but after i don’t know what to do when i resume the game?

Thank you.


You should implement your own reloadAllTexture.


I’m a newby with cocos2dx and i prefer to show you some piece of code to determine what is wrong because i surely made some mistakes in my code :smiley:

Here is how i initialize my sprite:

CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage(elem->getPath());

if (texture)


and the main which is reloaded OpenGl context and reloadTexture is the same as in helloWorld.

What can i do to get back my texture in reloadTexture?

Thank you, have a good day.


Problem solved thank you :smiley: