player: 初始化分析
Posted ZhYQ_note
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了player: 初始化分析相关的知识,希望对你有一定的参考价值。
//1、 //cocos 程序开始运行时执行的函数 bool AppDelegate::applicationDidFinishLaunching() { // initialize director auto director = Director::getInstance(); director->setProjection(Director::Projection::_2D); // turn on display FPS director->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don‘t call this director->setAnimationInterval(1.0 / 60); director->startAnimation(); // register lua engine auto engine = LuaEngine::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(engine); lua_State* L = engine->getLuaStack()->getLuaState(); lua_module_register(L); // If you want to use Quick-Cocos2dx-Community, please uncomment below code quick_module_register(L); LuaStack* stack = engine->getLuaStack(); // stack->setXXTEAKeyAndSign("2dxLua", "XXTEA"); //主要来看下这部分: StartupCall *call = StartupCall::create(this); call->startup(); return true; } //2、 void StartupCall::startup() { auto engine = LuaEngine::getInstance(); auto stack = engine->getLuaStack(); const ProjectConfig &project = _app->_project; // set search path // 设置工程搜索路径 string path = FileUtils::getInstance()->fullPathForFilename(project.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("/"); string workdir; if (p != path.npos) { workdir = path.substr(0, p); // Lua 代码文件的搜索需要包含src stack->addSearchPath(workdir.c_str()); // cc.FileUtils的文件搜索去掉src目录 size_t p = workdir.find_last_of("/"); workdir = path.substr(0, p); FileUtils::getInstance()->addSearchPath(workdir); } // load framework if (project.isLoadPrecompiledFramework()) { const string precompiledFrameworkPath = project.getPrecompiledFrameworkPath(); stack->loadChunksFromZIP(precompiledFrameworkPath.c_str()); } // load script string env = "__LUA_STARTUP_FILE__=\""; env.append(path); env.append("\""); engine->executeString(env.c_str()); CCLOG("------------------------------------------------"); CCLOG("LOAD LUA FILE: %s", path.c_str()); CCLOG("------------------------------------------------"); engine->executeScriptFile(path.c_str()); // track start event trackLaunchEvent(); } //跟踪启动事件 void StartupCall::trackEvent(const char *eventName) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) const char *platform = "win"; #elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) const char *platform = "mac"; #else const char *platform = "UNKNOWN"; #endif HTTPRequest *request = HTTPRequest::createWithUrl(NULL, "http://www.google-analytics.com/collect", kCCHTTPRequestMethodPOST); request->addPOSTValue("v", "1"); request->addPOSTValue("tid", "UA-84326395-1"); request->addPOSTValue("cid", Native::getOpenUDID().c_str()); request->addPOSTValue("t", "event"); request->addPOSTValue("an", "player"); request->addPOSTValue("av", cocos2dVersion()); request->addPOSTValue("ec", platform); request->addPOSTValue("ea", eventName); request->start(); }
以上是关于player: 初始化分析的主要内容,如果未能解决你的问题,请参考以下文章
SKSpriteNode对象初始化在iPhone 6 plus中显示不正确的分析及解决
如何使用 Swift 使用此代码片段为 iOS 应用程序初始化 SDK?
Android 逆向整体加固脱壳 ( DEX 优化流程分析 | DexPrepare.cpp 中 dvmOptimizeDexFile() 方法分析 | /bin/dexopt 源码分析 )(代码片段