在2dx中用cclog输出日志,但是在vs的控制台中由于信息很多,很难发现。可以用下面方法,会重新启动一个黑色的控制台来输出日志
- #include"main.h"
- #include"AppDelegate.h"
- #include"CCEGLView.h"
- #include"net/NetWork.h"
- #include"adapter/Routeradapter.h"
- USING_NS_CC;
- #defineUSE_WIN32_CONSOLE
- intAPIENTRY_tWinMain(HINSTANCEhInstance,
- HINSTANCEhPrevInstance,
- LPTSTRlpCmdLine,87); background-color:inherit; font-weight:bold">intnCmdshow)
- {
- UNREFERENCED_ParaMETER(hPrevInstance);
- UNREFERENCED_ParaMETER(lpCmdLine);
- #ifdefUSE_WIN32_CONSOLE
- AllocConsole();
- freopen("CONIN$","r",stdin);
- freopen("CONOUT$","w",stdout);
- freopen("CONOUT$",stderr);
- #endif
- //createtheapplicationinstance
- CCEGLView*eglView=CCEGLView::sharedOpenGLView();
- eglView->setViewName("MT");
- //eglView->setFrameSize(480,320);
- returnCCApplication::sharedApplication()->run();
- FreeConsole();
- #endif
- }
注意宏定义: #defineUSE_WIN32_CONSOLE 要加上这一句,否则在编译android文件的时候会编译出错,要想在控制台上输出中文,要用printf函数,否则会使乱码。