【问题标题】:Cocos2dx v3.4 Release Mode ErrorCocos2dx v3.4 发布模式错误
【发布时间】:2015-05-06 19:00:30
【问题描述】:

我正在尝试使用 CMake 在发布模式下构建我的游戏。我禁用了 DEBUG_MODE 并成功构建了项目,但是当我运行它时出现错误,我没有进入调试模式。

这是调用堆栈。

KernelBase.dll!763d2f71()   Unknown
    [Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll]    
    [External Code] 
>   SortingGame.exe!BackgroundBuilder::configureTimeLabel(const cocos2d::Vec2 timeContainerEndPos) Line 236 C++
    SortingGame.exe!BackgroundBuilder::configureTimeContainerSprite() Line 226  C++
    SortingGame.exe!GameScene::configureTimeContainerSprite() Line 352  C++
    SortingGame.exe!GameScene::configureScene() Line 210    C++
    SortingGame.exe!GameScene::init() Line 130  C++
    SortingGame.exe!GameScene::create() Line 25 C++
    SortingGame.exe!LoadingScreen::onKeyPressed(cocos2d::EventKeyboard::KeyCode keyCode, cocos2d::Event * event) Line 168   C++
    [External Code] 
    SortingGame.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 24   C++
    [External Code]

BackgroundBuilder::configureTimeContainerSprite() 函数只被调用一次。如果我在BackgroundBuilder::BackgroundBuilder() 中调用BackgroundBuilder::configureTimeContainerSprite(),则错误不会出现在BackgroundBuilder::configureTimeContainerSprite() 中,而是出现在main.cpp 文件的return Application::getInstance()->run(); 行中。这里的错误也是一样的。 当我使用 Visual Studio 2013 构建项目时,我遇到了同样的错误。

【问题讨论】:

标签: c++ cmake cocos2d-x release cocos2d-x-3.0


【解决方案1】:

我发现了问题所在。我将资源预加载到游戏中的方式似乎存在问题。在TitleScreen::init() 我使用这个函数来加载资产。 GameManager::getInstance()->getResourceManager()->loadTextures("GameScene", callback); 这是CocosResourceManager::loadTextures()的实现

void CocosResourceManager::loadTextures(const std::string &sceneName, const std::function<void(std::string sceneName, int loadedAssetCount, int totalAssetCount)> &callback)
{
    std::map<std::string, std::string> assets = parseAssetsArray(sceneName);
    int totalAsset = assets.size(), loadedAsset = 0;
    for (auto value : assets) {
        TextureCache::getInstance()->addImage(value.second);
        loadedAsset++;
        callback(sceneName, loadedAsset, totalAsset);
    }
}

当我不使用该功能加载资产时,发布模式不会崩溃。当我预加载它们时,我将它与我之前在上面发布的堆栈跟踪一起使用。 TextureCache::getInstance()-&gt;addImageAsync(); 和 TextureCache::getInstance()-&gt;addImage(); 都会发生这种情况 我是否以错误的方式预加载?谁能解释为什么会这样?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-16
    • 1970-01-01
    • 2021-09-20
    • 1970-01-01
    • 1970-01-01
    • 2012-05-19
    • 2012-10-06
    • 1970-01-01
    相关资源
    最近更新 更多