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. Tigase XMPP Server

    Tigase XMPP Server是我们的旗舰服务器端软件,提供XMPP服务或实例通信(IC)服务.最基本的解释是Tigase是一个聊天服务器,但它远不止于此.聊天是其可能的应用程序之一,但任何类型 ...

  2. Django---MTV和MVC的了解,Django的模版语言变量和逻辑,常见的模板语言过滤器,自定义过滤器,CSRF了解,Django的母版(继承extends,块block,组件include,静态文件的加载load static),自定义simple_tag和inclusion_tag

    Django---MTV和MVC的了解,Django的模版语言变量和逻辑,常见的模板语言过滤器,自定义过滤器,CSRF了解,Django的母版(继承extends,块block,组件include,静 ...

  3. 【MySQL】数据库事务深入分析

    一.前言 只有InnoDB引擎支持事务,下边的内容均以InnoDB引擎为默认条件 二.常见的并发问题 1.脏读 一个事务读取了另一个事务未提交的数据 2.不可重复读 一个事务对同一数据的读取结果前后不 ...

  4. Vue – 基础学习(1):对生命周期和钩子函的理解

    一.简介 先贴一下官网对生命周期/钩子函数的说明(先贴为敬):所有的生命周期钩子自动绑定 this 上下文到实例中,因此你可以访问数据,对属性和方法进行运算.这意味着你不能使用箭头函数来定义一个生命周 ...

  5. LP线性规划初识

    认识LP 线性规划(Linear Programming) 特指目标函数和约束条件皆为线性的最优化问题. 目标函数: 多个变量形成的函数 约束条件: 由多个等式/不等式形成的约束条件 线性规划: 在线 ...

  6. prometheus学习系列十: Prometheus AlertManager配置文件说明

    alertmanager配置文件说明 alertmanager是通过命令行标记和配置文件配置的,命令行标记配置不可变的系统参数,配置文件定义抑制规则.通知路由和通知接收器.可以通过官方提供的routi ...

  7. prometheus学习系列四: Prometheus详述

    数据模型 Prometheus 是将所有数据存为时序数据. 每个时序数据是由指标名称和可选的键值对(称之为标签)唯一标识. 度量类型 counter: 单调递增的计数器,如果标识已经服务的请求数量可以 ...

  8. SQL注入(1)

    一.注入点的判断及猜解1.加入单引号 ’提交,结果:如果出现错误提示,则该网站可能就存在注入漏洞.2.数字型判断是否有注入;语句:and 1=1 ;and 1=2 (经典).' and '1'=1(字 ...

  9. HTML通用模板

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  10. 排序算法合集(C++实现)

    摘要 排序操作在程序设计中是非常基础和常见的,也是算法的基础部分,我对几种常见的比较排序算法进行了整理. 暴力排序(violence sort) 思想:遍历数组,每次遍历都在未排序的部分找到最小元素的 ...