main.cpp打开USE_WIN32_CONSOLE输出
#include "main.h" #include "AppDelegate.h" #include "CCEGLView.h" #define USE_WIN32_CONSOLE USING_NS_CC; // uncomment below line, open debug console // #define USE_WIN32_CONSOLE int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); #ifdef USE_WIN32_CONSOLE AllocConsole(); freopen("CONIN$", "r", stdin); freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); #endif
#include "main.h" #include "AppDelegate.h" #include "CCEGLView.h" #define USE_WIN32_CONSOLE USING_NS_CC; // uncomment below line, open debug console // #define USE_WIN32_CONSOLE int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); #ifdef USE_WIN32_CONSOLE AllocConsole(); freopen("CONIN$", "r", stdin); freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); #endif
CCEGLView* eglView = CCEGLView::sharedOpenGLView(); eglView->setViewName("游戏名"); eglView->setFrameSize(960, 1440);
修改AppDelegate.cpp里面启动的js脚步
#if JSB_ENABLE_DEBUGGER ScriptingCore::getInstance()->enableDebugger(); ScriptingCore::getInstance()->runScript("main.debug.js"); #else ScriptingCore::getInstance()->runScript("游戏名-jsb.js"); #endif
和屏幕大小
// Set the design resolution CCEGLView::sharedOpenGLView()->setDesignResolutionSize(960, 640, kResolutionShowAll);
在ScriptingCore.cpp(D:\DevTool\cocos2d-x-2.2.2\cocos2d-x-2.2.2\scripting\javascript\bindings)
void ScriptingCore::reportError(JSContext *cx, const char *message, JSErrorReport *report) { js_log("%s:%u:%s\n", report->filename ? report->filename : "<no filename=\"filename\">", (unsigned int) report->lineno, message); };
里面加个断点,方便看脚步出错问题