cocos2dx 3.17 lua 运行带控制台输出

1.查看新建项目里面的win32/main.cpp.

2.修改入口函数内容

#include "main.h"
#include "SimulatorWin.h"
#include <shellapi.h>

#define USE_WIN32_CONSOLE  //加入

int WINAPI _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

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

    int ret = SimulatorWin::getInstance()->run(); //下面加入

#ifdef USE_WIN32_CONSOLE
    FreeConsole();
#endif

    return ret;
    
}

3.重新编译运行就可以了。

发布了4 篇原创文章 · 获赞 0 · 访问量 1573

猜你喜欢

转载自blog.csdn.net/zhoumo753/article/details/103999281