用lua_v3.2的时候,console是默认开启,下了最新的v3.7后,发现不开了,开关也不好找。
仔细观察工程目录,发现多了很多文件
SimulatorWin.h
现在改成main.cpp --> SimulatorWin --> AppDelegate
SimulatorWin会先设置一些参数,比如是否开始log,将log输出到某一个文件
ProjectConfig.h
如果在运行程序的时候,传递一些参数,这些参数将会被在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
可以在SimulatorWin的run函数里添加
_project.setWriteDebugLogToFile(true);
game01.exe -write-debug-log debug.log
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
game01.exe -resolution 480x320