当前位置: 首页>>代码示例>>C++>>正文


C++ CCLuaStack::setXXTEAKeyAndSign方法代码示例

本文整理汇总了C++中CCLuaStack::setXXTEAKeyAndSign方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLuaStack::setXXTEAKeyAndSign方法的具体用法?C++ CCLuaStack::setXXTEAKeyAndSign怎么用?C++ CCLuaStack::setXXTEAKeyAndSign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCLuaStack的用法示例。


在下文中一共展示了CCLuaStack::setXXTEAKeyAndSign方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: applicationDidFinishLaunching

bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
    pDirector->setProjection(kCCDirectorProjection2D);

    // set FPS. the default value is 1.0/60 if you don't call this
    pDirector->setAnimationInterval(1.0 / 60);

    // register lua engine
    CCLuaEngine *pEngine = CCLuaEngine::defaultEngine();
    CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);

    CCLuaStack *pStack = pEngine->getLuaStack();
	lua_State* L = pStack->getLuaState();
    
	luaopen_MapRuntimeC_luabinding(L);


#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    // load framework
   // pStack->loadChunksFromZIP("res/framework_precompiled.zip");

	// 如果设置了 -e 和 -ek 要加上下面这句
    // pStack->setXXTEAKeyAndSign("aaa", 3);
    // 如果设置了 -e 和 -ek -es 则要加上下面这句
    pStack->setXXTEAKeyAndSign("aaa", 3, "XT", 2);
    // load framework
    pStack->loadChunksFromZIP("res/script/framework_precompiled.zip");
    pStack->loadChunksFromZIP("res/script/game.zip");
    pStack->executeString("require 'main'");

	
    // set script path
    //string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("scripts/main.lua");
	string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("scripts/main.lua");
#else
    // load framework
    if (m_projectConfig.isLoadPrecompiledFramework())
    {
        const string precompiledFrameworkPath = SimulatorConfig::sharedDefaults()->getPrecompiledFrameworkPath();
		const string precompiledGamePath = SimulatorConfig::sharedDefaults()->getPrecompiledGamePath();
		pStack->setXXTEAKeyAndSign("aaa", 3, "XT", 2);//加密操作
        pStack->loadChunksFromZIP(precompiledFrameworkPath.c_str());
		pStack->loadChunksFromZIP(precompiledGamePath.c_str());

		pStack->executeString("require 'main'");
    }

	

    // set script path
    string path = CCFileUtils::sharedFileUtils()->fullPathForFilename(m_projectConfig.getScriptFileRealPath().c_str());
#endif

    size_t pos;
    while ((pos = path.find_first_of("\\")) != std::string::npos)
    {
        path.replace(pos, 1, "/");
    }
    size_t p = path.find_last_of("/\\");
    if (p != path.npos)
    {
        const string dir = path.substr(0, p);
        pStack->addSearchPath(dir.c_str());

        p = dir.find_last_of("/\\");
        if (p != dir.npos)
        {
            pStack->addSearchPath(dir.substr(0, p).c_str());
        }
    }

    string env = "__LUA_STARTUP_FILE__=\"";
    env.append(path);
    env.append("\"");
    //pEngine->executeString(env.c_str());

	CCLOG("==",env.c_str());
    CCLOG("------------------------------------------------");
    CCLOG("LOAD LUA FILE: %s", path.c_str());
    CCLOG("------------------------------------------------");
    //pEngine->executeScriptFile(path.c_str());
	//pEngine->executeScriptFile("main.lua");

    return true;
}
开发者ID:jackdevelop,项目名称:test,代码行数:88,代码来源:AppDelegate.cpp

示例2: applicationDidFinishLaunching


//.........这里部分代码省略.........
    std::string pathBase = "res_phone/";
#else
    std::string pathBase = "res/";
#endif
    
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    // load framework
    pathBase = "res_phone/";
    std::string pre_zip = "framework_precompiled.zip";
    pre_zip = pathBase+pre_zip;
    
    CCLog("cpp loadChunksFromZIP begin-- ");
    pStack->loadChunksFromZIP(pre_zip.c_str());
    CCLog("cpp loadChunksFromZIP end-- ");
    // set script path
    string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("scripts/main.lua");
#endif
    
    size_t pos;
    while ((pos = path.find_first_of("\\")) != std::string::npos)
    {
        path.replace(pos, 1, "/");
    }
    size_t p = path.find_last_of("/\\");
    if (p != path.npos)
    {
        const string dir = path.substr(0, p);
        pStack->addSearchPath(dir.c_str());
        
        p = dir.find_last_of("/\\");
        if (p != dir.npos)
        {
            pStack->addSearchPath(dir.substr(0, p).c_str());
        }
    }
    
    string env = "__LUA_STARTUP_FILE__=\"";
    env.append(path);
    env.append("\"");
    
    pStack->setXXTEAKeyAndSign("CFgrrwCFewrf", 12);
    
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    
#if 0
    std::string rootDir = CCFileUtils::sharedFileUtils()->getWritablePath();
#else
    std::string rootDir =  CCFileUtils::sharedFileUtils()->getWritablePath();
#endif
    std::string dataPath =   cachePath + "game.dat";
    CCLog("LOAD MAIN.LUA dataPath=%s",dataPath.c_str());
    CCLog("LOAD MAIN.LUA begin--");
    bool runCompliedScript = true;                         ////////////////////////------------------USE COMPILED RESOURCE??
    if (runCompliedScript) {
        
        if(pStack->loadChunksFromZIP(dataPath.c_str()))
        {
            CCLog("LOAD MAIN.LUA end2--");
            pEngine->executeString("require \"main\"");
            CCLog("LOAD MAIN.LUA end3--");
        }
    }
    else
    {

    CCLog("LOAD MAIN.LUA end5--");
    
    pEngine->executeString("print(\"blah\")");
    pEngine->executeString("CCLuaLog(\"blah\")");
    std::string dataPath = rootDir+pathBase + "scripts/main.lua";
    CCLog("dataPath:%s",dataPath.c_str());
        if(pStack->executeScriptFile(dataPath.c_str()))
        {

    CCLog("LOAD MAIN.LUA end6--");
            pEngine->executeString("require \"main\"");
        }
    }
    CCLog("LOAD MAIN.LUA end7--");
    pEngine->executeString(env.c_str());
    CCLog("LOAD MAIN.LUA end4--");
    CCLog("LOAD MAIN.LUA end4--");
#else
    
	string dataPath = CCFileUtils::sharedFileUtils()->getWritablePath();
	dataPath += "res"DIRECTORY_SEPARATOR"game2.dat";
	if(pStack->loadChunksFromZip(dataPath.c_str()))
	{
		pEngine->executeString("require \"main\"");
	}
	else
	{
        CCLOG("------------------------------------------------");
        CCLOG("LOAD LUA FILE: %s", path.c_str());
        CCLOG("------------------------------------------------");
        pEngine->executeScriptFile(path.c_str());
	}
#endif
    return true;
}
开发者ID:NexusEast,项目名称:Flipull,代码行数:101,代码来源:AppDelegate.cpp


注:本文中的CCLuaStack::setXXTEAKeyAndSign方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。