本文整理汇总了C++中CCLuaStack::loadChunksFromZIP方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLuaStack::loadChunksFromZIP方法的具体用法?C++ CCLuaStack::loadChunksFromZIP怎么用?C++ CCLuaStack::loadChunksFromZIP使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLuaStack
的用法示例。
在下文中一共展示了CCLuaStack::loadChunksFromZIP方法的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();
tolua_ChessRule_luabinding_open(L);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// load framework
pStack->loadChunksFromZIP("res/framework_precompiled.zip");
// set script path
string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("scripts/main.lua");
#else
// load framework
if (m_projectConfig.isLoadPrecompiledFramework())
{
const string precompiledFrameworkPath = SimulatorConfig::sharedDefaults()->getPrecompiledFrameworkPath();
pStack->loadChunksFromZIP(precompiledFrameworkPath.c_str());
}
// 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("------------------------------------------------");
CCLOG("LOAD LUA FILE: %s", path.c_str());
CCLOG("------------------------------------------------");
pEngine->executeScriptFile(path.c_str());
return true;
}
示例2: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching()
{
//#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
// //Lua版本、JS版本请参考并在lua侧或js侧调用,同时请在该applicationFinishLaunching接口调用dataeye.h中的接口注入接口
// //添加DataEye需要配置的appID和channelId
// //APPID 是一组32位的代码,可以在g.dataeye.com创建游戏后获得.
// //“937042C1192B1833CD8DF4895B281674”的部分要按照实际情况设置,一定要记得替换哦
// //DC_AFTER_LOGIN模式适用于有账号体系的游戏,后面必须要调用DCAccount login,否则不会上报数据。
// //DEFAULT模式适用于不存在账号体系的游戏(如单机),SDK会用设备ID作为用户的ID
// //请选择合适于自己游戏的上报模式
// DCAgent::setReportMode(DC_AFTER_LOGIN);
// DCAgent::setDebugMode(true);
// DCAgent::onStart("937042C1192B1833CD8DF4895B281674", "DataEye");
//#endif
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
pDirector->setProjection(kCCDirectorProjection2D);
/////.........COPY 3 FILES FIRST. //////////////////
string Srcfile = CCFileUtils::sharedFileUtils()->getSearchPaths()[0] + "res_phone/";//game.dat"; //game.dat
string cachePath = CCFileUtils::sharedFileUtils()->getWritablePath() + "res_iphone/";
string lockPath = cachePath + ".lock";
fstream _file;
_file.open(lockPath.c_str(),ios::in);
CCLog("Srcfile:%s",Srcfile.c_str());
CCLog("cachePath:%s",cachePath.c_str());
CCLog("lockPath:%s",lockPath.c_str());
if (!_file)
{
if ( CheckDir(cachePath.c_str()) )
{
CCLog("create :%s success!",cachePath.c_str());
MyCopyFile(Srcfile + "game.dat",cachePath + "game.dat");
MyCopyFile(Srcfile + "framework_precompiled.zip",cachePath + "framework_precompiled.zip");
ofstream fout;
fout.open(cachePath+".lock",ios::app);
fout<<" "<<endl;
}
else
{
CCLog("create :%s failed!",cachePath.c_str());
}
}
else
{
CCLog(".lock exists!");
}
// 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();
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
lua_State *tolua_s = pStack->getLuaState();
#endif
#if defined(ENCRYPT_RESOURCE_ENABLED) && ENCRYPT_RESOURCE_ENABLED == 1
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());
//.........这里部分代码省略.........