天天看点

cocos2x-Lua中如何调用控制台打印信息

cocos2x-Lua中如何调用控制台打印信息

在你项目目录下,win32的main.cpp文件中添加如下代码

cocos2x-Lua中如何调用控制台打印信息

#include “main.h”

#include “SimulatorWin.h”

#include <shellapi.h>

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 &quot; , &quot; r &quot; , s t d i n ) ; f r e o p e n ( &quot; C O N O U T &quot;, &quot;r&quot;, stdin); freopen(&quot;CONOUT ","r",stdin);freopen("CONOUT”, “w”, stdout);

freopen(“CONOUT$”, “w”, stderr);

#endif

auto simulator = SimulatorWin::getInstance();
return simulator->run();
           

#ifdef USE_WIN32_CONSOLE

FreeConsole();

#endif

}

重新运行一下项目,oK