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运行分析
随机推荐
- [MySql] - Windows MySql 8.x 手动zip包安装与外网访问登录权限设定
MySql 8.x官方下载地址 https://dev.mysql.com/downloads/mysql/8.0.html https://cdn.mysql.com//Downloads/MySQ ...
- drf序列化与反序列化
序列化器-Serializer 定义序列化器 Django REST framework中的Serializer使用类来定义,须继承自rest_framework.serializers.Serial ...
- python爬虫---爬虫的数据解析的流程和解析数据的几种方式
python爬虫---爬虫的数据解析的流程和解析数据的几种方式 一丶爬虫数据解析 概念:将一整张页面中的局部数据进行提取/解析 作用:用来实现聚焦爬虫的吧 实现方式: 正则 (针对字符串) bs4 x ...
- 从 html 元素继承 box-sizing
在大多数情况下我们在设置元素的 border 和 padding 并不希望改变元素的 width,height值,这个时候我们就可以为该元素设置 box-sizing:border-box;. 我不希 ...
- CSS中:和::
一个冒号是伪类,两个冒号是伪元素 伪类可以独立于文档的元素来分配样式,且可以分配给任何元素,逻辑上和功能上类类似,但是其是预定义的.不存在于文档树中且表达方式也不同,所以叫伪类.伪元素所控制的内容和一 ...
- C# 判断域名或ip+端口号 是否能正常连接?
private static ManualResetEvent TimeoutObject = new ManualResetEvent(false); /// <summary> /// ...
- html, js,css应用文件路径规则
web前端一般常用文件 .html .css .js.但是当用css文件和html引入资源(比如图片)时,路径可能不相同.下面总结了几条. 使用相对路径引入规则: html或者js引入图片,按照htm ...
- python之栈与队列
这个在官网中list支持,有实现. 补充一下栈,队列的特性: 1.栈(stacks)是一种只能通过访问其一端来实现数据存储与检索的线性数据结构,具有后进先出(last in first out,LIF ...
- 92. 反转链表 II.反转从位置 m 到 n 的链表。请使用一趟扫描完成反转。
public ListNode reverseBetween(ListNode head, int m, int n) { ListNode dummy = new ListNode(0); //虚拟 ...
- zabbix--邮件告警报错“Support for SMTP authentication was not compiled in”
zabbix 邮件告警报错“Support for SMTP authentication was not compiled in” 邮件报警失败:Support for SMTP authentic ...