cocos2d-x 2.1.4 android版Home到桌面,然后重新返回游戏,会出现黑屏(Black Screen),声音一直在播放。这是2.1.4的一个bug,2.1.5解决了这个bug。但是由于种种原因,游戏不能立马更换2.1.5 sdk,就去github上找到了这个问题的解决日志。
修改的地方:
1.cocos2dx/platform/CCFileUtils.cpp
2. cocos2dx/platform/CCPlatformMacros.h
3.自己android程序 jni/main/main.cpp
cocos2dx/platform/CCFileUtils.cpp
void CCFileUtils::setSearchResolutionsOrder(const std::vector<std::string>& searchResolutionsOrder)
{
bool bExistDefault = false;
+ m_fullPathCache.clear();
m_searchResolutionsOrderArray.clear();
for (std::vector<std::string>::const_iterator iter = searchResolutionsOrder.begin(); iter != searchResolutionsOrder.end(); ++iter)
{
@@ -694,7 +695,8 @@ const std::vector<std::string>& CCFileUtils::getSearchPaths()
void CCFileUtils::setSearchPaths(const std::vector<std::string>& searchPaths)
{
bool bExistDefaultRootPath = false;
-
+
+ m_fullPathCache.clear();
m_searchPathArray.clear();
for (std::vector<std::string>::const_iterator iter = searchPaths.begin(); iter != searchPaths.end(); ++iter)
{
@@ -741,6 +743,7 @@ void CCFileUtils::addSearchPath(const char* path_)
void CCFileUtils::setFilenameLookupDictionary(CCDictionary* pFilenameLookupDict)
{
+ m_fullPathCache.clear();
CC_SAFE_RELEASE(m_pFilenameLookupDict);
m_pFilenameLookupDict = pFilenameLookupDict;
CC_SAFE_RETAIN(m_pFilenameLookupDict);
cocos2dx/platform/CCPlatformMacros.h
-#if (CC_TARGET_PLATFORM == CC_PLATFORM_EMSCRIPTEN)
+#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_EMSCRIPTEN)
#define CC_ENABLE_CACHE_TEXTURE_DATA 1
#else
#define CC_ENABLE_CACHE_TEXTURE_DATA 0
jni/hellocpp/main.cpp
AppDelegate *pAppDelegate = new AppDelegate();
CCApplication::sharedApplication()->run();
}
- /*
else
{
ccDrawInit();
@@ -39,7 +38,6 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
CCDirector::sharedDirector()->setGLDefaultValues();
}
- */
}