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


C++ CCLuaEngine::addSearchPath方法代码示例

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


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

示例1: applicationDidFinishLaunching

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

    // turn on display FPS
    pDirector->setDisplayStats(true);

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

	pDirector->runWithScene( TestScene::create() );
#if 0

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

#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

#endif

    return true;
}
开发者ID:starcid,项目名称:Song,代码行数:35,代码来源:AppDelegate.cpp

示例2: applicationDidFinishLaunching

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

    // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
//     pDirector->enableRetinaDisplay(true);

    // turn on display FPS
    pDirector->setDisplayStats(true);

    // 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);

	std::string dirPath = "luaScript";
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    CCString* pstrFileContent = CCString::createWithContentsOfFile((dirPath + "/controller.lua").c_str());
    if (pstrFileContent)
    {
        pEngine->executeString(pstrFileContent->getCString());
    }
#else
    std::string path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath((dirPath + "/controller.lua").c_str());
    pEngine->addSearchPath(path.substr(0, path.find_last_of("/") - dirPath.length()).c_str());
    pEngine->executeScriptFile(path.c_str());
#endif
    return true;
}
开发者ID:acc85,项目名称:cocos2d-x,代码行数:33,代码来源:AppDelegate.cpp

示例3: applicationDidFinishLaunching

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


    CCSize frameSize = pEGLView->getFrameSize();

    pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionExactFit);

    if (frameSize.height > mediumResource.size.height)
    {
        pDirector->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
    }
    // if the frame's height is larger than the height of small resource size, select medium resource.
    else if (frameSize.height > smallResource.size.height)
    {
        pDirector->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
    }
    // if the frame's height is smaller than the height of medium resource size, select small resource.
    else
    {
        pDirector->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
    }


    // turn on display FPS
    //pDirector->setDisplayStats(true);



    // 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 *tolua_s = pStack->getLuaState();
    tolua_extensions_ccb_open(tolua_s);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
    pStack = pEngine->getLuaStack();
    tolua_s = pStack->getLuaState();
    tolua_web_socket_open(tolua_s);
#endif

#if (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY)
    CCFileUtils::sharedFileUtils()->addSearchPath("script");
#endif

    std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("scripts/main.lua");
    pEngine->addSearchPath(path.substr(0, path.find_last_of('/')).c_str());
    pEngine->executeScriptFile(path.c_str());

    return true;
}
开发者ID:danjia,项目名称:GameForMom,代码行数:59,代码来源:AppDelegate.cpp

示例4: init

bool LuaGenerator::init() {
	CCLuaEngine *E = CCLuaEngine::defaultEngine();	
    CCScriptEngineManager::sharedManager()->setScriptEngine(E);
	L = E->getLuaState();

	string path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("lua/animat.lua");
	int r = luaL_dofile(L, path.c_str());
	if (r != 0) {
		CCLog("[LuaLoader Error]Load system file [animat.lua] fail, %s!", lua_tostring(L, -1));
		lua_pop(L, 1);
		CCAssert(false, "Load animat.lua file error!");	
		return false;
	}
    E->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());

	return true;
}
开发者ID:Coolxiaoo,项目名称:AnimateDesigner,代码行数:17,代码来源:luagenerator.cpp

示例5:

void
MCScript::run()
{
    CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
    
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    CCString* pstrFileContent = CCString::createWithContentsOfFile(scriptPath_->getCString());
    if (pstrFileContent)
    {
        pEngine->executeString(pstrFileContent->getCString());
    }
#else
    std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename(scriptPath_->getCString()).c_str();
    pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
    pEngine->executeScriptFile(path.c_str());
#endif
}
开发者ID:edison9888,项目名称:__graduation_project,代码行数:17,代码来源:MCScript.cpp

示例6: applicationDidFinishLaunching

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

    // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
    // pDirector->enableRetinaDisplay(true);

	// turn on display FPS
	pDirector->setDisplayFPS(true);

	// pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);

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

	// init lua engine
    CCLuaEngine* pEngine = CCLuaEngine::sharedEngine();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
	unsigned long size;
	char *pFileContent = (char*)CCFileUtils::getFileData("hello.lua", "r", &size);

	if (pFileContent)
	{
	    // copy the file contents and add '\0' at the end, or the lua parser can not parse it
	    char *pCodes = new char[size + 1];
	    pCodes[size] = '\0';
	    memcpy(pCodes, pFileContent, size);
	    delete[] pFileContent;

	    pEngine->executeString(pCodes);
	    delete []pCodes;
	}
#endif

#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
	string path = CCFileUtils::fullPathFromRelativePath("hello.lua");
	pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
    pEngine->executeScriptFile(path.c_str());
#endif

	return true;
}
开发者ID:zhouwenbin,项目名称:cocos2d-x,代码行数:45,代码来源:AppDelegate.cpp

示例7: initLuaEngine

void AppDelegate::initLuaEngine()
{
#ifdef ENABLE_LUA_ENGINE
    // register lua engine
    CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
    CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
    // Note: init lua search path
    string path = GameResourceManager::sharedManager()->storedFullPathFromRelativePath("Script/main.lua");
    string scriptPath = path.substr(0, path.find_last_of("S"));
    pEngine->addSearchPath(scriptPath.c_str());

    CCLuaStack *pStack = pEngine->getLuaStack();
    lua_State *tolua_s = pStack->getLuaState();
    tolua_extensions_ccb_open(tolua_s);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
    pStack = pEngine->getLuaStack();
    tolua_s = pStack->getLuaState();
    //tolua_web_socket_open(tolua_s);
#endif
#endif
}
开发者ID:niuzb,项目名称:hellopet,代码行数:21,代码来源:AppDelegate.cpp

示例8: applicationDidFinishLaunching

bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
    
    // turn on display FPS
    pDirector->setDisplayStats(true);

    // 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);

    std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("hello.lua");
    pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
    pEngine->executeScriptFile(path.c_str());

    return true;
}
开发者ID:ntop001,项目名称:cocos2d-x,代码行数:22,代码来源:AppDelegate.cpp

示例9: applicationDidFinishLaunching

bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
    
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 800, kResolutionShowAll);

    // turn on display FPS
    pDirector->setDisplayStats(false);

    // 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();
    lua_State *state = pEngine->getLuaStack()->getLuaState();
    tolua_MyExt_open(state);

    CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);

	//加载cjson
	CCLuaStack *pStack = pEngine->getLuaStack(); 
    lua_State* L = pStack->getLuaState(); 
    luaopen_lua_extensions(L); 


#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32 && ANALYTICS_UMENG == 1)
	loadAnalyticsPlugin();
    g_pAnalytics->setDebugMode(false);
    g_pAnalytics->startSession(s_strAppKey.c_str());
    g_pAnalytics->setCaptureUncaughtException(true);

    AnalyticsUmeng* pUmeng = dynamic_cast<AnalyticsUmeng*>(g_pAnalytics);
    //AnalyticsFlurry* pFlurry = dynamic_cast<AnalyticsFlurry*>(g_pAnalytics);
    if (pUmeng != NULL)
    {
        pUmeng->updateOnlineConfig();
        pUmeng->setDefaultReportPolicy(AnalyticsUmeng::REALTIME);
    }
	/*
    if (pFlurry != NULL)
    {
        pFlurry->setReportLocation(true);
        pFlurry->logPageView();
        // const char* sdkVersion = pFlurry->getSDKVersion();
        pFlurry->setVersionName("1.1");
        pFlurry->setAge(20);
        pFlurry->setGender(AnalyticsFlurry::MALE);
        pFlurry->setUserId("123456");
        pFlurry->setUseHttps(false);
    }*/
#endif

CCLog("before to load lua file");
CCLog("platform ");

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    CCLog("before android add search path");
	//pEngine->addSearchPath((CCFileUtils::sharedFileUtils()->getWritablePath() + "script/").c_str());
	//CCFileUtils::sharedFileUtils()->addSearchPath((CCFileUtils::sharedFileUtils()->getWritablePath() + "script/").c_str());
	
    CCString* pstrFileContent = CCString::createWithContentsOfFile("Entry");
	
    CCLOG("%s","read script from phone memory");
    
    pEngine->executeString(pstrFileContent->getCString());
    
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
    
    CCLuaStack *pStack = pEngine->getLuaStack();
    lua_State *tolua_s = pStack->getLuaState();
    tolua_AppstorePurchase_open(tolua_s);
    
    std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("Entry");
    pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
	CCString* pstrFileContent = CCString::createWithContentsOfFile("Entry");
	pEngine->executeString(pstrFileContent->getCString());
#else
    std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("Entry");
    pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());

	CCString* pstrFileContent = CCString::createWithContentsOfFile("Entry");
	const char * res = pstrFileContent->getCString();

	int len = strlen(res);
	int remain_len = len % 8;
	int desSize = len+1;
	if(remain_len>0){
		desSize += 8 - remain_len;
	}
	unsigned char* des = (unsigned char*)malloc(desSize*sizeof(unsigned char));

	//加密脚本
	file_encrypt(res,des,desSize);
	pEngine->executeString(file_decrypt(des,desSize));//解密脚本

	//unsigned long desSize = 0;
	//unsigned char * enc = CCFileUtils::sharedFileUtils()->getFileData(path.c_str(), "rb", &desSize);
	//char * res = file_decrypt(enc,desSize);
//.........这里部分代码省略.........
开发者ID:liyonghelpme,项目名称:fenshenUI,代码行数:101,代码来源:AppDelegate.cpp


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