cocos2dx-3.1.5中lua显示控制台输出窗口

  • Post author:
  • Post category:其他


版本:cocos2dx-3.1.5+vs2013

打开当前项目的 main.cpp

main.cpp路径

文件内容应该是这样的

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

int WINAPI _tWinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPTSTR    lpCmdLine,
    int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);
    auto simulator = SimulatorWin::getInstance();
    return simulator->run();
}

修改成下面的:

#include "main.h"
//#include "SimulatorWin.h"
#include "AppDelegate.h"
//#include <shellapi.h>
USING_NS_CC;
#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();
    AppDelegate app;
    int ret = Application::getInstance()->run();
#ifdef USE_WIN32_CONSOLE
    FreeConsole();
#endif

    return ret;
}

运行如下图所示

调试窗口



版权声明:本文为mhtqq809201原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。