Cocos2d-x 打开WIN32 控制台

来源:互联网 发布:淘宝外围活动 编辑:程序博客网 时间:2024/05/22 15:47

首先我们在main.cpp里面定义一个宏,用来控制是否要开启控制台显示

#define USE_WIN32_CONSOLE

项目调用初始化控制台

#ifdef USE_WIN32_CONSOLEAllocConsole();#endif


调用成功之后分离

#ifdef USE_WIN32_CONSOLEFreeConsole();#endif



在Cocos2d-x项目中,使用CCLog或者Cout来输出

CCLog("CpGameWindow::init()");std::cout<<"ceshi"<<std::endl;

效果如图:



完整main.cpp代码

#include "main.h"#include "AppDelegate.h"#include "CCEGLView.h"USING_NS_CC;#define USE_WIN32_CONSOLEint APIENTRY _tWinMain(HINSTANCE hInstance,                       HINSTANCE hPrevInstance,                       LPTSTR    lpCmdLine,                       int       nCmdShow){    UNREFERENCED_PARAMETER(hPrevInstance);    UNREFERENCED_PARAMETER(lpCmdLine);#ifdef USE_WIN32_CONSOLEAllocConsole();#endif    // create the application instance    AppDelegate app;    EGLView eglView;    eglView.init("Chess",320,480);    return Application::getInstance()->run();#ifdef USE_WIN32_CONSOLEFreeConsole();#endif}


原创粉丝点击