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


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

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


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

示例1: 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
    CCScriptEngineProtocol* pEngine = CCLuaEngine::engine();
    CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);

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

    return true;
}
开发者ID:csdnnet,项目名称:hiygame,代码行数:33,代码来源: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->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);

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

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
	unsigned long size;
#ifdef KILLA
	char *pFileContent = (char*)CCFileUtils::getFileData("boot.kia", "r", &size);
#else
	char *pFileContent = (char*)CCFileUtils::getFileData("boot.lua", "r", &size);
#endif

	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) || (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
#ifdef KILLA
	string path = CCFileUtils::fullPathFromRelativePath("boot.kia");
#else
	string path = CCFileUtils::fullPathFromRelativePath("boot.lua");
#endif

    pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
    pEngine->executeScriptFile(path.c_str());
#endif 

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


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