zoukankan      html  css  js  c++  java
  • VS2010-win32下cocos2dx控制台打印的方法

    在xcode中  直接使用printf 或者 cout<<""<<endl;可以直接在控制台打印

    但是在VS2010 却死活不好用   真郁闷

    -----------------10-9更新----------------

    下面的代码在 自己建立的项目里都已经存在啦

    AllocConsole();
    freopen("CONIN$", "r", stdin);
    freopen("CONOUT$", "w", stdout);
    freopen("CONOUT$", "w", stderr);

    就在 项目中的 main.cpp中

    7   // uncomment below line, open debug console
    8   #define USE_WIN32_CONSOLE

    将第八行的 注释去掉就好了

    好了 至此 我们已经可以到引出所有的 输出了 都可以用自己语言规则 打印啦

    -----------------9-6更新------------------

    今天又知道一中方法可以直接打印出 C/C++的输出信息

    	AllocConsole();
    	freopen("CONIN$", "r", stdin);
    	freopen("CONOUT$", "w", stdout);
    	freopen("CONOUT$", "w", stderr);
    

    在cocos2d-x的项目中如果加入次代码 就会在打开程序的时候额外打开一个 命令提示符 的窗口用与显示C/C++ 的打印

    Lua 中也可以使用

    在Lua文件中还有一个打印的方法就是 用CCLuaLog();

    用法和CCLog()类似.

     

    ----------8-13-----------------------

    后来查资料发现可以用CCLog();打印

    但是里面的参数 必须是char[] 输出的时候记得转换

    char p[10] ;
    itoa(touchPoint.x, p, 10); 
    CCLog(p);

    记录一下下

    以下是修改代码:

    main.cpp:

    #include "main.h"
    #include "../Classes/AppDelegate.h"
    #include "CCEGLView.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$", "r", stdin);
    freopen("CONOUT$", "w", stdout);
    freopen("CONOUT$", "w", stderr);
    #endif


        // create the application instance
        AppDelegate app;
        CCEGLView* eglView = CCEGLView::sharedOpenGLView();
        eglView->setFrameSize(960, 640 );
        return CCApplication::sharedApplication()->run();




    #ifdef USE_WIN32_CONSOLE
    FreeConsole();
    #endif
    }


  • 相关阅读:
    (网页)中的简单的遮罩层
    (后端)shiro:Wildcard string cannot be null or empty. Make sure permission strings are properly formatted.
    (网页)jQuery的时间datetime控件在AngularJs中使用实例
    Maven Myeclipse 搭建项目
    MyBatis 环境搭建 (一)
    java 常用方法
    XML 基础
    JS BOM
    js 事件
    js 的使用原则
  • 原文地址:https://www.cnblogs.com/snake-hand/p/3143231.html
Copyright © 2011-2022 走看看