quick player运行分析
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运行分析的更多相关文章
- quick: setup_mac.sh分析
//quick: setup_mac.sh分析 //quick: setup_mac.sh分析#!/bin/bash //获取并打印根目录QUICK_V3_ROOTDIR="$( cd &q ...
- JVM 自定义类加载器在复杂类情况下的运行分析
一.自定义类加载器在复杂类情况下的运行分析 1.使用之前创建的类加载器 public class MyTest16 extends ClassLoader{ private String classN ...
- Java开源运行分析工具(转)
FProfiler FProfiler是一个非常快的Java profiler.它利用BCEL和log4j来记录每个方法从开始到结尾的日记.FProfiler可以用来在你的应用程序,Servle ...
- 一个Flask运行分析
当我们安装好Flask环境之后,创建好项目,就会自动生成下面这段代码: from flask import Flask app = Flask(__name__) @app.route('/') de ...
- quick player no exit
QuickXDev插件自动升级后player no exist 昨晚上QuickXDev插件运行还ok,今天打开电脑启动sublime text2后,右键run with player提示player ...
- IDEA 程序直接运行分析
今天用IDEA运行SpringBoot程序,启动时始终报错说读取不到datasource的url配置. 分析代码的resources目录,是有配置文件的,配置也是正常的.如下图: 后来经人指点,是因为 ...
- player: 初始化分析
//1. //cocos 程序开始运行时执行的函数 bool AppDelegate::applicationDidFinishLaunching() { // initialize director ...
- 开源安卓播放器:Dolphin Player 简单分析
Dolphin播放器(Dolphin Player)是一款开源的音频和视频播放器,它支持大多数的音频和视频文件模式,也支持大部分的字幕文件格式.它是基于ffmpeg的. 项目主页:http://cod ...
- WAMP运行分析
随机推荐
- Linux中Crontab的使用
一.安装依赖 yum install cronie 二.添加 Crontab crontab -e 三.查看crontab内容 crontab -l 其中常见的一些内容 例子: # 每月的最后1天 0 ...
- jsp代码中实现下拉选项框的回显代码
用到了c标签库:首先要在jsp中导入jstl的核心库标签 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/js ...
- EXT.NET Combox下拉Grid
<ext:ComboBox ID="cmbCategory" runat="server" TypeAhead="true" Forc ...
- kylin2.4.1订单案例详细构建流程
一.Hive订单数据仓库构建: hive表创建可以在命令行中直接完成,也可以在Hue中完成,本文在Hue中的完成,如下图: 下文的样例文本文件下载地址:https://files-cdn.cnblog ...
- Java 之 Object 类
一.Object 概述 java.lang.Object 类是 Java 语言中的根类,即所有类的父类. 在对象实例化的时候,最终找的父类就是 Object. 如果一个类没有特别指定父类,那么默认则 ...
- 如何检测Windows中的横向渗透攻击
一.前言 横向渗透攻击技术是复杂网络攻击中广泛使用的一种技术,特别是在高级持续威胁(Advanced Persistent Threats,APT)中更加热衷于使用这种攻击方法.攻击者可以利用这些技术 ...
- 渗透 Facebook 的思路与发现
0x00 写在故事之前 身一位渗透测试人员,比起 Client Side 的弱点,我更喜欢 Server Side 的攻击,能够直接控制服务器并获得权限操作 SHELL 才爽 . 当然一次完美的渗透出 ...
- Easy2game使用
每个独享IP服务器,开设3-5个高速接口IP,用户可自行选择当地连接速度快的接口接入服务器,服务器再为用户自动分配所绑定的独享IP连接至游戏服务器,可保证连接的稳定性,统一性 打开软件 添加程序 服务 ...
- BERT解析及文本分类应用
目录 前言 BERT模型概览 Seq2Seq Attention Transformer encoder部分 Decoder部分 BERT Embedding 预训练 文本分类试验 参考文献 前言 在 ...
- Windows Server 2012 R2 配置IIS
efs:http://www.07net01.com/storage_networking/windows_server_2012_anzhuang_IIS8_bingzhichi_asp_45191 ...