本文整理汇总了C++中CCLuaEngine::executeGlobalFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLuaEngine::executeGlobalFunction方法的具体用法?C++ CCLuaEngine::executeGlobalFunction怎么用?C++ CCLuaEngine::executeGlobalFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLuaEngine
的用法示例。
在下文中一共展示了CCLuaEngine::executeGlobalFunction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
pDirector->setDisplayStats(true);
pDirector->setAnimationInterval(1.0 / 60);
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(960, 640, kResolutionShowAll);
// 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
CCFileUtils::sharedFileUtils()->addSearchPath("luaScript");
//cocoswidget lua binding open api
tolua_Lua_cocos2dx_widget_open(tolua_s);
std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("main.lua");
pEngine->executeScriptFile(path.c_str());
pEngine->executeGlobalFunction("main");
return true;
}