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. 第一阶段:Java基础 1.JAVA开发介绍---2. JVM、JRE、JDK之间的关系

    JDK :英文名称(Java Development Kit),Java 开发工具包,是针对 Java 开发员的产品.jdk 是整个 Java 开发的核心,包括了Java运行环境JRE.Java工具和 ...

  2. 浅谈Object.prototype.toString.call()方法

    在JavaScript里使用typeof判断数据类型,只能区分基本类型,即:number.string.undefined.boolean.object.对于null.array.function.o ...

  3. IOS/Safari下document对象的scrollHeight值比Chrome更大

    之前写滚动加载更多需求时,写了这样一段错误代码 应该获取滚动列表的scrollHeight.clientHeight和scrollTop而不是整个页面的. 因为整个页面不仅包括了滚动列表,还包括了头部 ...

  4. Django 之组合搜索

    现在很多网站都会有这样的组合搜索功能,其实质是几个模型之间组合对数据库进行查询,并将结果显示到页面上. 每一行都是一个模型,模型之间有着连表关系(一对多.多对多等) 模型设计 总共四个模型:分别为方向 ...

  5. ubuntu16安装php开发环境

    一,安装 ubuntu 工具 sudo apt install -y git curl zsh vim 二,安装php 和 php-fpm , redis ,memcached 等 sudo apt ...

  6. The 2019 Asia Yinchuan First Round Online Programming F. Moving On

    t题目链接:https://nanti.jisuanke.com/t/41290 思路:题目意思很容易想到floyd,但是由于危险度的限制,我们该怎么跑floyd呢. 一开始理解错题目了,以为u-&g ...

  7. 洛谷 P1162 填涂颜色题解

    题目描述 由数字00组成的方阵中,有一任意形状闭合圈,闭合圈由数字11构成,围圈时只走上下左右44个方向.现要求把闭合圈内的所有空间都填写成22.例如:6 \times 66×6的方阵(n=6n=6) ...

  8. xtrabackup 使用

    创建具有完全备份所需的最小权限的数据库用户的SQL示例如下 mysql> CREATE USER 'bkpuser'@'%' IDENTIFIED BY 's3cret';mysql> G ...

  9. 第六篇 -- LINQ to XML

    一.LINQ to XML常用成员 LINQ to XML的成员, 属性列表: 属性 说明 Document 获取此 XObject 的 XDocument  EmptySequence  获取空的元 ...

  10. 项目Beta冲刺随笔集合

    班级:软件工程1916|W 作业:项目Beta冲刺 团队名称:SkyReach 目标:完成项目Beta版本 项目Github地址 评审表 团队博客汇总 队员学号 队员姓名 个人博客地址 备注 2216 ...