• Cocos2d 使用控制台打印的方法


    1.打开当前项目的win32解决方案。

    2.在解决方案管理器的win32文件夹下打开main.cpp

    3.增加以下代码:

    #define USE_WIN32_CONSOLE
    
    //以下加到入口函数
    #ifdef USE_WIN32_CONSOLE
        AllocConsole();
        freopen("CONIN$", "r", stdin);
        freopen("CONOUT$", "w", stdout);
        freopen("CONOUT$", "w", stderr);
    #endif

    修改后的main.cpp

    #include "main.h"
    #include "AppDelegate.h"
    #include "cocos2d.h"
    
    USING_NS_CC;
    
    #if _MSC_VER > 1800
    #pragma comment(lib,"libcocos2d_2015.lib")
    #pragma comment(lib,"libbox2d_2015.lib")
    #pragma comment(lib,"libSpine_2015.lib")
    #pragma comment(lib,"librecast_2015.lib")
    #pragma comment(lib,"libbullet_2015.lib")
    #else
    #pragma comment(lib,"libcocos2d_2013.lib")
    #pragma comment(lib,"libbox2d_2013.lib")
    #pragma comment(lib,"libSpine_2013.lib")
    #pragma comment(lib,"librecast_2013.lib")
    #pragma comment(lib,"libbullet_2013.lib")
    #endif
    
    #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$", "r", stdin);
        freopen("CONOUT$", "w", stdout);
        freopen("CONOUT$", "w", stderr);
    #endif
    
        // create the application instance
        AppDelegate app;
        return Application::getInstance()->run();
    }
  • 相关阅读:
    面向对象之补充
    继续面向对象之成员与组合
    面向对象初阶
    模块和包
    异常处理
    [Array]448. Find All Numbers Disappeared in an Array
    [Array]485. Max Consecutive Ones
    [Array] 561. Array Partition I
    [Array] 566. Reshape the Matrix
    opencv3.1线性可分svm例子及函数分析
  • 原文地址:https://www.cnblogs.com/kingBook/p/5174616.html
Copyright © 2020-2023  润新知