cocos2dx_lua_v3.7 open console
2015-07-26 21:43
483 查看
用lua_v3.2的时候,console是默认开启,下了最新的v3.7后,发现不开了,开关也不好找。
仔细观察工程目录,发现多了很多文件
原来是main.cpp --> AppDelegate
现在改成main.cpp --> SimulatorWin --> AppDelegate
SimulatorWin会先设置一些参数,比如是否开始log,将log输出到某一个文件
位于\frameworks\cocos2d-x\tools\simulator\libsimulator\lib\ProjectConfig目下,SimulatorWin的配置都会从这里读取
如果在运行程序的时候,传递一些参数,这些参数将会被在SimulatorWin进行设置
比如要开启log
将
改成
当然,能不改源码是最好的
以上两种操作都会将Log输出到debug.log文件里面
以上代码位于
除了可以打开log外,还可以设置运行窗口的大小
需要注意的是480和320之间的是小写字母x,而不是*
仔细观察工程目录,发现多了很多文件
SimulatorWin.h
原来是main.cpp --> AppDelegate
现在改成main.cpp --> SimulatorWin --> AppDelegate
SimulatorWin会先设置一些参数,比如是否开始log,将log输出到某一个文件
ProjectConfig.h
位于\frameworks\cocos2d-x\tools\simulator\libsimulator\lib\ProjectConfig目下,SimulatorWin的配置都会从这里读取
如果在运行程序的时候,传递一些参数,这些参数将会被在SimulatorWin进行设置
比如要开启log
前置条件
打开game01\frameworks\runtime-src\Classes\ide-support\CodeIDESupport.h
将
#define CC_CODE_IDE_DEBUG_SUPPORT 0
改成
#define CC_CODE_IDE_DEBUG_SUPPORT 1
方法1
可以在SimulatorWin的run函数里添加_project.setWriteDebugLogToFile(true);
当然,能不改源码是最好的
方法2
打开cmd,进入projectDir/simulator/win32,打如下命令game01.exe -write-debug-log debug.log
以上两种操作都会将Log输出到debug.log文件里面
关于运行winSimulator可以设置的参数
void ProjectConfig::parseCommandLine(const vector<string> &args) { auto it = args.begin(); while (it != args.end()) { string arg = *it; if (arg.compare("-workdir") == 0) { ++it; if (it == args.end()) break; setProjectDir(*it); if (_writablePath.length() == 0) setWritablePath(*it); } else if (arg.compare("-writable-path") == 0) { ++it; if (it == args.end()) break; setWritablePath(*it); } else if (arg.compare("-entry") == 0) { ++it; if (it == args.end()) break; setScriptFile(*it); } else if (arg.compare("-landscape") == 0) { setFrameSize(cocos2d::Size(DEFAULT_HEIGHT, DEFAULT_WIDTH)); } else if (arg.compare("-portrait") == 0) { setFrameSize(cocos2d::Size(DEFAULT_WIDTH, DEFAULT_HEIGHT)); } else if (arg.compare("-resolution") == 0) { ++it; if (it == args.end()) break; const string& sizeStr(*it); size_t pos = sizeStr.find('x'); int width = 0; int height = 0; if (pos != sizeStr.npos && pos > 0) { string widthStr, heightStr; widthStr.assign(sizeStr, 0, pos); heightStr.assign(sizeStr, pos + 1, sizeStr.length() - pos); width = atoi(widthStr.c_str()); height = atoi(heightStr.c_str()); setFrameSize(cocos2d::Size(width, height)); } } else if (arg.compare("-scale") == 0) { ++it; if (it == args.end()) break; float scale = atof((*it).c_str()); setFrameScale(scale); } else if (arg.compare("-write-debug-log") == 0) { ++it; if (it == args.end()) break; setDebugLogFilePath((*it)); setWriteDebugLogToFile(true); } else if (arg.compare("-console") == 0) { ++it; if (it == args.end()) break; if ((*it).compare("enable") == 0) { setShowConsole(true); } else { setShowConsole(false); } } else if (arg.compare("-position") == 0) { ++it; if (it == args.end()) break; const string& posStr(*it); size_t pos = posStr.find(','); int x = 0; int y = 0; if (pos != posStr.npos && pos > 0) { string xStr, yStr; xStr.assign(posStr, 0, pos); yStr.assign(posStr, pos + 1, posStr.length() - pos); x = atoi(xStr.c_str()); y = atoi(yStr.c_str()); setWindowOffset(cocos2d::Vec2(x, y)); } } else if (arg.compare("-debugger") == 0) { ++it; if (it == args.end()) break; if ((*it).compare("codeide") == 0) { setDebuggerType(kCCRuntimeDebuggerCodeIDE); } else if ((*it).compare("studio") == 0) { setDebuggerType(kCCRuntimeDebuggerStudio); } } else if (arg.compare("-app-menu") == 0) { _isAppMenu = true; } else if (arg.compare("-resize-window") == 0) { _isResizeWindow = true; } else if (arg.compare("-retina-display") == 0) { _isRetinaDisplay = true; } else if (arg.compare("-port") == 0) { CCLOG("TODO:"); } else if (arg.compare("-listen") == 0) { ++it; setBindAddress((*it)); } else if (arg.compare("-search-path") == 0) { ++it; vector<string> pathes = split((*it), ';'); setSearchPath(pathes); } ++it; } }
以上代码位于
\frameworks\cocos2d-x\tools\simulator\libsimulator\lib\ProjectConfig
除了可以打开log外,还可以设置运行窗口的大小
game01.exe -resolution 480x320
需要注意的是480和320之间的是小写字母x,而不是*
相关文章推荐
- cocos2d-x 3.4 中文乱码解决之道
- Cocos2d-x使用Luajit将Lua脚本编译成bytecode,启用加密
- 基于Cocos2d-x的英雄联盟皮肤选择菜单
- cocos2d-x 颜色
- Cocos2dx_世界坐标和模型坐标
- 使用Spine软件制作骨骼动画供Cocos2d-x使用
- Cocos2d-x开发教程 第四节 深入Action
- Cocos2d-x 3.1.1 学习日志8--2分钟让你知道cocos2d-x3.1.1 文本类别
- cocos2d-xUI编译器导出的json,程序中怎么读取?遇到自定义字体UILabelBMFont,怎么在程序中修改他的值?怎么将json再次导入编译器中?
- 在Cocos2d-Lua中使用ProtoBuf(Xcode配置方法)
- cocos2d 用MotionStreak给骨骼动画的刀加拖尾(刀光拖尾)
- cocos3——10.cocos2dx架构复习
- 8、Cocos2dx 3.0三,找一个小游戏开发3.0存储器管理的版本号
- cocos2d-x convertToWorldSpace和convertToNodeSpace
- 关于cocos2dx如何通过jni进行c++与java的交互
- cocos2dx Android签名总结
- cocos2d-x 3.x游戏教程 - Eight
- cocos2dx 创建项目脚本
- Cocos2d-x3.3它DrawPrimitivesTest分析
- Ubuntu 与 cocos2d-x