博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
player: 初始化分析
阅读量:5260 次
发布时间:2019-06-14

本文共 3356 字,大约阅读时间需要 11 分钟。

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

 

转载于:https://www.cnblogs.com/ZhYQ-Note/p/5924322.html

你可能感兴趣的文章
第一页 - 工具的使用(webstorm)
查看>>
Linux 进程资源用量监控和按用户设置进程限制
查看>>
IE浏览器整页截屏程序(二)
查看>>
D3.js 之 d3-shap 简介(转)
查看>>
制作满天星空
查看>>
类和结构
查看>>
CSS3选择器(二)之属性选择器
查看>>
adidas crazylight 2018 performance analysis review
查看>>
typeset shell 用法
查看>>
python 之 循环语句
查看>>
心得25--JDK新特性9-泛型1-加深介绍
查看>>
[转]ceph网络通信模块_以monitor模块为例
查看>>
HDOJ 1754 I Hate It(线段树基本操作)
查看>>
latex tree
查看>>
安装NVIDIA驱动时禁用自带nouveau驱动
查看>>
HDU-1255 覆盖的面积 (扫描线)
查看>>
css3学习01
查看>>
【USACO】 奶牛会展
查看>>
ActiveMQ笔记之点对点队列(Point-to-Point)
查看>>
继承和多态
查看>>