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


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

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


在下文中一共展示了CCLuaEngine::executeScriptFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
    
    // 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);
    
    std::vector<std::string> searchPaths;
    searchPaths.push_back("cocosbuilderRes");

#if CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY
    searchPaths.push_back("TestCppResources");
#endif
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);

    pEngine->executeScriptFile("luaScript/controller.lua");

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

示例2: applicationDidFinishLaunching

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

	// Set the design resolution
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionShowAll);
#else
	CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionNoBorder);
#endif

    // 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 = CCUtils::getExternalOrFullPath("main.lua");
    pEngine->executeScriptFile(path.c_str());

    return true;
}
开发者ID:nightwolf-chen,项目名称:cocos2dx-classical,代码行数:28,代码来源:AppDelegate.cpp

示例3: 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);

    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("Welcome.lua");
    pEngine->executeScriptFile(path.c_str());

    return true;
}
开发者ID:plter,项目名称:Cocos2dXLessons20131011,代码行数:34,代码来源:AppDelegate.cpp

示例4: 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

示例5: 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

示例6: applicationDidFinishLaunching

bool AppDelegate::applicationDidFinishLaunching()
{
    // Create lua engine
    CCLuaEngine* engine = CCLuaEngine::defaultEngine();
    assert(engine);
    if (!engine)
        return false;
    engine->executeScriptFile("actorData.lua");
    CCScriptEngineManager::sharedManager()->setScriptEngine(engine);
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
//   CCEGLView::sharedOpenGLView()->setDesignResolutionSize(1136, 640,kResolutionExactFit);
    // 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);
   
    
    // create a scene. it's an autorelease object
    CCScene *pScene =  CCScene::create();
    pScene->addChild(GameRoot::shareGameRoot()->getSceneLoading());
  
    // run
    pDirector->runWithScene(pScene);

    return true;
}
开发者ID:9cat,项目名称:dotawar,代码行数:29,代码来源:AppDelegate.cpp

示例7: 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

示例8: API_LoadLuaFile

// 加载LUA脚本
void API_LoadLuaFile( char *szLUAFileName)
{
	CCLOG("API_LoadLuaFile = %s",szLUAFileName);

	CCLuaEngine* pEngine = CCLuaEngine::defaultEngine(); 
	std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename(szLUAFileName);
	pEngine->executeScriptFile(path.c_str());

}
开发者ID:recter,项目名称:MGameNotes,代码行数:10,代码来源:gameluaapi.cpp

示例9: executeLua

int LuaEngineUtils::executeLua(const char *luaFileName)
{
    CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
    if(!sm_bInited){
        sm_bInited = true;
        // register lua engine
        CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
    }
    return pEngine->executeScriptFile(luaFileName);
}
开发者ID:qingzhizhu,项目名称:QingLibCocos2dx,代码行数:10,代码来源:LuaEngineUtils.cpp

示例10: 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();

    // load framework
    if (m_projectConfig.isLoadPrecompiledFramework())
    {
        const string precompiledFrameworkPath = SimulatorConfig::sharedDefaults()->getPrecompiledFrameworkPath();
        pStack->loadChunksFromZip(precompiledFrameworkPath.c_str());
    }

    // load script
    string path = CCFileUtils::sharedFileUtils()->fullPathForFilename(m_projectConfig.getScriptFileRealPath().c_str());
    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("------------------------123------------------------");
    CCLOG("LOAD LUA FILE: %s", path.c_str());
    CCLOG("------------------------------------------------");
    pEngine->executeScriptFile(path.c_str());

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

示例11: executeScriptFile

void LuaUtil::executeScriptFile(const std::string &filePath)
{
    CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    CCString* pstrFileContent = CCString::createWithContentsOfFile(filePath.c_str());
    if (pstrFileContent)
    {
        pEngine->executeString(pstrFileContent->getCString());
    }
#else
    std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename(filePath.c_str());
    pEngine->executeScriptFile(path.c_str());
#endif
}
开发者ID:9mobile,项目名称:ResourceManager,代码行数:14,代码来源:LuaUtil.cpp

示例12: gameEnter

void AssetsUpdateLayer::gameEnter()
{
    //CCFileUtils::getInstance()->addSearchPath("ccb/");

    // localization init
    //Localization::getInstance()->init();
    // CCLayer init
    //GameScene::getInstance();
    //Data init
    //DataManager::getInstance()->init();
    // Battle init 
    //BattleInitData::getInstance();

    CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
    std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("scripts/main.lua");
    CCLOG("* path [%s] *", path.c_str());
    //pEngine->executeScriptFile(path.c_str());

    CCLuaStack *pStack = pEngine->getLuaStack();

    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());
            CCLog("added %s", 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: exec %s, env %s", path.c_str(), env.c_str());
    CCLog("------------------------------------------------");
    pEngine->executeScriptFile(path.c_str());
    
}
开发者ID:sharpfforg,项目名称:us,代码行数:50,代码来源:AssetsUpdateLayer.cpp

示例13: applicationDidFinishLaunching

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

	//    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionNoBorder);

	// 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 / GAME_FPS);
	StringVector kSearchPaths;
	StringVector kOrders;

	if (!initSearchPaths(kSearchPaths))
	{
		CCLOG("Initialise searching path failed!");
		return false;
	}

	if (false == autoSizeMachineResolutions(kOrders))
	{
		return false;
	}

	CCFileUtils::sharedFileUtils()->setSearchResolutionsOrder(kOrders);

	pDirector->setContentScaleFactor(
		m_kResourceSize.width / m_kDesignSize.width);

	// register lua engine
	CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();

	CCLuaStack *pStack = pEngine->getLuaStack();
	lua_State *tolua_s = pStack->getLuaState();
	tolua_extensions_ccb_open(tolua_s);

	CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
	CCFileUtils::sharedFileUtils()->setSearchPaths(kSearchPaths);

	std::string strLuaPath = CCFileUtils::sharedFileUtils()->fullPathForFilename(
		ENTRY_LUA_FUNC);
	CCLOG("Will exceute %s\n",strLuaPath.c_str());
	pEngine->executeScriptFile(strLuaPath.c_str());

	return true;
}
开发者ID:bihai,项目名称:GouJi,代码行数:49,代码来源:AppDelegate.cpp

示例14: 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);

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

[! if CC_USE_LUA]
    // 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->executeScriptFile(path.c_str());
#endif
[! else]
    // create a scene. it's an autorelease object
    CCScene *pScene = HelloWorld::scene();

    // run
    pDirector->runWithScene(pScene);
[! endif]
    return true;
}
开发者ID:PashaCher,项目名称:cc-tetris,代码行数:49,代码来源:AppDelegate.cpp

示例15: 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);

    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
        
    std::vector<std::string> searchPaths;
    searchPaths.push_back("cocosbuilderRes");
    searchPaths.insert(searchPaths.begin(), "scenetest/ArmatureComponentTest");
    searchPaths.insert(searchPaths.begin(), "scenetest/AttributeComponentTest");
    searchPaths.insert(searchPaths.begin(), "scenetest/BackgroundComponentTest");
    searchPaths.insert(searchPaths.begin(), "scenetest/EffectComponentTest");
    searchPaths.insert(searchPaths.begin(), "scenetest/LoadSceneEdtiorFileTest");
    searchPaths.insert(searchPaths.begin(), "scenetest/ParticleComponentTest");
    searchPaths.insert(searchPaths.begin(), "scenetest/SpriteComponentTest");
    searchPaths.insert(searchPaths.begin(), "scenetest/TmxMapComponentTest");
    searchPaths.insert(searchPaths.begin(), "scenetest/UIComponentTest");
    searchPaths.insert(searchPaths.begin(), "scenetest/TriggerTest");

#if CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY
    searchPaths.push_back("TestCppResources");
    searchPaths.push_back("script");
#endif
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);

    pEngine->executeScriptFile("luaScript/controller.lua");

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


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