leto
leto

Reputation: 119

Cocos2d-x using compiled lua script doesn't work on Android

I've been trying to make the HelloLua example to work in Android. It works if the hello.lua is not in compiled form using luac. But if I compile the hello.lua and upload it in my Android phone, it just gives me a black screen. Can anyone help me out in this?

This is the code in the AppDelegate::applicationDidFinishLaunching()

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    CCString* pstrFileContent = CCString::createWithContentsOfFile("hello.lua");
    if (pstrFileContent)
    {
        pEngine->executeString(pstrFileContent->getCString());
    }
#else
    std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("hello.lua");
    pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
    pEngine->executeScriptFile(path_c_str());
#endif

Seems that compiled lua works when I'm running in Windows but not in Android.

Upvotes: 1

Views: 637

Answers (1)

lhf
lhf

Reputation: 72312

The man page for luac says that "Precompiled chunks are not portable across different architectures".

Upvotes: 2

Related Questions