Updated on May 17, 2013: for the previously mentioned resource release problem, cocos2d-x 2.1.3 has been resolved, that is, do not release resources after the interruption, the estimation method is similar to the previously mentioned, I have not carefully studied ....
During the debugging process, I found that if the game is suspended when the processing is interrupted, the problem may occur due to improper methods, and I will experience the problem. When I return, I will quit the game directly, or the page is not displayed. Later, it was found that if the pause interface layer was created, it would be okay to create it in the appdelegate: applicationdidenterbackground method ~ If you create an application in the appdelegate: applicationwillenterforeground () method, the above problem may occur ~
Let's talk about audio interruptions ~ In fact, there is a little bit of soul in the sound interruption, that is, when the sound is interrupted, you can stop it directly and play it back, but the Android system found a disgusting problem, that is, when the game directly powers off the screen, and then return, in the screen lock interface, the game continues, meaning that the screen lock interface has called appdelegate: applicationwillenterforeground ()~ There is no way to solve the mechanism problem ~
Certificate ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Today, I tested the game sound interruption on my Android phone. What I found was that after the game was interrupted and returned, I found the game stuck for a long time ~
Post online ~ It is found that the game resources have been released and will be reloaded when it comes back ~ Some heroes in the group say it is the reason for cctexturecache ~
I tested it on iOS and found no problem. Then I started to find the cctexturecache problem ~ A macro is found.
/** Reload all textures
It's only useful when the value of cc_enable_cache_texture_data is 1
*/
Static void reloadalltextures ();
It is clearly related to the macro cc_enable_cache_texture_data.
Find the source and find
/** @ Def cc_enable_cache_texture_data
Enable it if you want to cache the texture data.
Basically, it's only enabled in Android
Its new in cocos2d-x since v0.99.5
*/
# If (cc_target_platform = cc_platform_android)
# Define cc_enable_cache_texture_data 1
# Else
# Define cc_enable_cache_texture_data 0
# Endif
Okay ~ Only Android uses this macro ~
Close, test, cry, black screen after going back ~
Continue to paste and find
Http://novacreo.com/%E7%A8%8B%E5%BA%8F%E7%BB%84/%E8%BF%94%E5%9B%9Eandroid%E6%B8%B8%E6%88%8F%E9%BB%91%E5%B1%8F%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95/
// The original post content is as follows:
Back to android game black screen Solution
These days around the cocos2d-x.org Forum, found that the author of the cocos2d-x put out a post, used to solve the problem of returning to the android game when loading resources black screen. The post will sink after a few days, so it will be transferred out for later query.
Three files need to be modified:
1) cocos2dx/platform/ccplatformmacros. h
Change line84 to # define cc_enable_cache_texture_data 0
2) cocos2dx/platform/Android/Java/src/org/cocos2dx/lib/cocos2dxglsurfaceview. Java
Comment out line167.
3) jin/hellocpp/Main. cpp under the android project directory
Comment out line32 ~ 43.
The basic principle is that after the activity enters the background, the texture cache is not cleared, so that after the activity returns to the foreground, the resource does not need to be re-loaded.
I tried it on my own game. It took about four seconds to switch back to the game before modification. It took no more than one second after modification.
However, this solution has some minor problems. When other surfaceview activities, such as AdMob advertisements, are integrated, they can only see advertisements instead of game images when they are switched back. Pablo tonello, a foreigner, replied to a post saying that AdMob was not integrated. I don't know what the problem is, so I need to study it slowly.
Zookeeper -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This post solves the problem, but there may be problems when inserting other sdks ~
Wait for resolution
Another post is to make a load interface for display to cover choppy videos ~~~~~~~~~~~~
Post address: http://blog.csdn.net/yanghuiliu/article/details/7362019
If you have a better solution, please let me know ~ Thx