本文共 1569 字,大约阅读时间需要 5 分钟。
在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 }转载地址:https://kaitiren.blog.csdn.net/article/details/9120271 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!