mac应用从AppController.mm源文件的applicationDidFinishLaunching函数启动:
  1 、
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[self installUncaughtExceptionHandler]; //创建player
auto player = player::PlayerMac::create();
player->setController(self); _isAlwaysOnTop = NO;
_debugLogFile = ; _buildTask = nil;
_isBuildingFinished = YES; // load QUICK_V3_ROOT from ~/.QUICK_V3_ROOT
// 从~/.QUICK_V3_ROOT获取quick根目录,我的:Users/staff/Documents/quick-3.3
NSMutableString *path = [NSMutableString stringWithString:NSHomeDirectory()];
[path appendString:@"/.QUICK_V3_ROOT"];
NSError *error = nil;
NSString *env = [NSString stringWithContentsOfFile:path
encoding:NSUTF8StringEncoding
error:&error];
if ([error code] || env.length == )
{
//没有这个配置则报错,提示你执行setup_mac.sh脚本
[self showAlertWithoutSheet:@"Please run \"setup_mac.sh\", set Quick-Cocos2dx-Community root path."
withTitle:@"quick player error"];
[[NSApplication sharedApplication] terminate:self];
} //_project.setQuickCocos2dxRootPath设置qucik根目录
env = [env stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
_project.setQuickCocos2dxRootPath([env cStringUsingEncoding:NSUTF8StringEncoding]); //分析命令行参数,设置_project的值,这个后面详细分析
[self updateProjectFromCommandLineArgs:&_project]; //创建WindowAndGLView,2分析
[self createWindowAndGLView]; //注册监听事件
[self registerEventsHandler]; //启动,3分析
[self startup];
} 、
- (void) createWindowAndGLView
{
//设置GLContextAttrs
GLContextAttrs glContextAttrs = {, , , , , };
GLView::setGLContextAttrs(glContextAttrs); float frameScale = _project.getFrameScale(); // create opengl view
cocos2d::Size frameSize = _project.getFrameSize(); //创建GLView,GLViewImpl是针对desktop平台实现的 文件在platform/desktop/CCGLViewImpl-desktop.h
const cocos2d::Rect frameRect = cocos2d::Rect(, , frameSize.width, frameSize.height);
GLViewImpl *eglView = GLViewImpl::createWithRect("player", frameRect, frameScale, _project.isResizeWindow()); auto director = Director::getInstance();
director->setOpenGLView(eglView); _window = eglView->getCocoaWindow();
[NSApp setDelegate:self];
[_window center]; if (_project.getProjectDir().length())
{
[self setZoom:_project.getFrameScale()];
Vec2 pos = _project.getWindowOffset();
if (pos.x != && pos.y != )
{
[_window setFrameOrigin:NSMakePoint(pos.x, pos.y)];
}
}
} 、
- (void) startup
{
FileUtils::getInstance()->setPopupNotify(false); //quick根目录
std::string path = _project.getQuickCocos2dxRootPath(); //如果设置了项目目录,则把项目目录设置为setDefaultResourceRootPath资源搜索默认目录
const string projectDir = _project.getProjectDir();
if (projectDir.length())
{
FileUtils::getInstance()->setDefaultResourceRootPath(projectDir.c_str());
//如果设置了log输出文件
if (_project.isWriteDebugLogToFile())
{
[self writeDebugLogToFile:_project.getDebugLogFilePath()];
}
} // set framework path
// 设置quick框架文件目录加入到搜索目录中_project.getQuickCocos2dxRootPath() + "quick/"
if (!_project.isLoadPrecompiledFramework())
{
FileUtils::getInstance()->addSearchPath(_project.getQuickCocos2dxRootPath() + "quick/");
} //设置可写目录
const string writablePath = _project.getWritableRealPath();
if (writablePath.length())
{
FileUtils::getInstance()->setWritablePath(writablePath.c_str());
} //显示Console,并且输出Configuration配置信息
if (_project.isShowConsole())
{
[self openConsoleWindow];
CCLOG("%s\n",Configuration::getInstance()->getInfo().c_str());
} //加载lua配置
[self loadLuaConfig];
[self adjustEditMenuIndex];
if (!_project.isAppMenu())
{
NSMenu *mainMenu = [[NSApplication sharedApplication] mainMenu];
NSArray *menuArray = [mainMenu itemArray];
for (int i = ; i < [menuArray count]; i++)
{
id onemenu = [menuArray objectAtIndex:i];
[mainMenu removeItem:onemenu];
}
} // app 运行app
_app = new AppDelegate();
_app->setProjectConfig(_project);
Application::getInstance()->run();
// After run, application needs to be terminated immediately.
[NSApp terminate: self];
} 、
- (void) loadLuaConfig
{
LuaEngine* pEngine = LuaEngine::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(pEngine); luaopen_PlayerLuaCore(pEngine->getLuaStack()->getLuaState());
luaopen_PlayerLuaCore_Manual(pEngine->getLuaStack()->getLuaState()); NSMutableString *path = [NSMutableString stringWithString:NSHomeDirectory()];
[path appendString:@"/"]; //
// set user home dir
//
lua_pushstring(pEngine->getLuaStack()->getLuaState(), path.UTF8String);
lua_setglobal(pEngine->getLuaStack()->getLuaState(), "__USER_HOME__"); //
// ugly: Add the opening project to the "Open Recents" list
//
lua_pushstring(pEngine->getLuaStack()->getLuaState(), _project.getProjectDir().c_str());
lua_setglobal(pEngine->getLuaStack()->getLuaState(), "__PLAYER_OPEN_TITLE__"); lua_pushstring(pEngine->getLuaStack()->getLuaState(), _project.makeCommandLine().c_str());
lua_setglobal(pEngine->getLuaStack()->getLuaState(), "__PLAYER_OPEN_COMMAND__"); //
// load player.lua file
// 加载player.lua文件
//
string playerCoreFilePath = _project.getQuickCocos2dxRootPath() + "quick/welcome/src/player.lua";
pEngine->executeScriptFile(playerCoreFilePath.c_str());
}

quick player运行分析的更多相关文章

  1. quick: setup_mac.sh分析

    //quick: setup_mac.sh分析 //quick: setup_mac.sh分析#!/bin/bash //获取并打印根目录QUICK_V3_ROOTDIR="$( cd &q ...

  2. JVM 自定义类加载器在复杂类情况下的运行分析

    一.自定义类加载器在复杂类情况下的运行分析 1.使用之前创建的类加载器 public class MyTest16 extends ClassLoader{ private String classN ...

  3. Java开源运行分析工具(转)

      FProfiler  FProfiler是一个非常快的Java profiler.它利用BCEL和log4j来记录每个方法从开始到结尾的日记.FProfiler可以用来在你的应用程序,Servle ...

  4. 一个Flask运行分析

    当我们安装好Flask环境之后,创建好项目,就会自动生成下面这段代码: from flask import Flask app = Flask(__name__) @app.route('/') de ...

  5. quick player no exit

    QuickXDev插件自动升级后player no exist 昨晚上QuickXDev插件运行还ok,今天打开电脑启动sublime text2后,右键run with player提示player ...

  6. IDEA 程序直接运行分析

    今天用IDEA运行SpringBoot程序,启动时始终报错说读取不到datasource的url配置. 分析代码的resources目录,是有配置文件的,配置也是正常的.如下图: 后来经人指点,是因为 ...

  7. player: 初始化分析

    //1. //cocos 程序开始运行时执行的函数 bool AppDelegate::applicationDidFinishLaunching() { // initialize director ...

  8. 开源安卓播放器:Dolphin Player 简单分析

    Dolphin播放器(Dolphin Player)是一款开源的音频和视频播放器,它支持大多数的音频和视频文件模式,也支持大部分的字幕文件格式.它是基于ffmpeg的. 项目主页:http://cod ...

  9. WAMP运行分析

随机推荐

  1. vue/react/angular开发的css架构思考

    前端开发现在已经从传统的后端web多页面开发模式转向前端单页SPA开发模式,而vuejs/react/angular则是开发SPA非常优秀的前端框架.组件化开发由react最早提出,vuejs后发优势 ...

  2. Java自学-数字与字符串 操纵字符串

    Java常见字符串方法 示例 1 : 获取字符 charAt(int index)获取指定位置的字符 package character; public class TestString { publ ...

  3. 【转载】 C#中ArrayList集合类的使用

    在C#的集合操作过程中,我们一般常用的集合类为List集合,List集合是一种强类型的泛型集合,其实还有一个ArrayList集合类,ArrayList集合类则非泛型类的集合,并且ArrayList集 ...

  4. Android源码分析(四)-----Android源码编译及刷机步骤

    一 : 获取源码: 每个公司服务器地址不同,以如下源码地址为例: http://10.1.14.6/android/Qualcomm/msm89xx/branches/msm89xx svn环境执行: ...

  5. Pandas 之 DataFrame 常用操作

    import numpy as np import pandas as pd This section will walk you(引导你) through the fundamental(基本的) ...

  6. 服务器架构前面加了防火墙,Nginx如何获取客户端真实ip???

    在大部分实际业务场景中,网站访问请求并不是简单地从用户(访问者)的浏览器直达网站的源站服务器,中间可能经过所部署的CDN.高防IP.WAF等代理服务器.例如,网站可能采用这样的部署架构:用户 > ...

  7. 机器学习笔记8:XGBoost

    目录 1 回顾一下决策树 2 XGBoost举例 2.1 问题和结果 2.2 第一棵树的计算方法 2.3 第二棵树的计算方法 3 XGBoost公式推导 3.1 第一种理解公式 3.2 第二种理解公式 ...

  8. k8s 之service资源介绍(三)

    kubernetes service资源 apiVersion: v1 kind: Service metadata: name: kubia spec: ports: - port: 80 targ ...

  9. csv、json 文件读取

    1.CSV 文件存储 1.1 写入 简单示例 import csv with open('data.csv', 'a') as csvfile: writer = csv.writer(csvfile ...

  10. centos 长久路由表

    由于用命令添加路由条目之后,重启程序后,条目会消失.所以需要用文件管理路由. 1.根据网卡创建路由表文件 vim /etc/sysconfig/network-scripts/route-eth0 2 ...