===================================================================================================
如果Android看不到CCLOG输出,可以打开项目下jni/XX/Application.mk文件, 在APP_CPPFLAGS : 后面加入 -DCOCOS2D_DEBUG=1
ios需要把Build Configuration设置成Debug
AppDelegate.cpp 加上一句
engine->executeString("print = release_print");
把build_native.bat里“set NDK_DEBUG=1” 这一行的注释去掉
===================================================================================================
cocos2dx lua让print 在andriod 输出log的方法
1.在cpp工程中搜索print( 定位到 int lua_print(lua_State * luastate),这个地方就是 lua中print函数的api
2.修改该函数
int lua_print(lua_State * luastate)
{
int nargs = lua_gettop(luastate);
std::string t;
for (int i=1; i <= nargs; i++)
{
if (lua_istable(luastate, i))
t += "table";
else if (lua_isnone(luastate, i))
t += "none";
else if (lua_isnil(luastate, i))
t += "nil";
else if (lua_isboolean(luastate, i))
{
if (lua_toboolean(luastate, i) != 0)
t += "true";
else
t += "false";
}
else if (lua_isfunction(luastate, i))
t += "function";
else if (lua_islightuserdata(luastate, i))
t += "lightuserdata";
else if (lua_isthread(luastate, i))
t += "thread";
else
{
const char * str = lua_tostring(luastate, i);
if (str)
t += lua_tostring(luastate, i);
else
t += lua_typename(luastate, lua_type(luastate, i));
}
if (i!=nargs)
t += "\t";
}
#ifdef ANDROID
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "%s", t.c_str());
#else
CCLOG("[LUA-print] %s", t.c_str());
#endif
return 0;
}
3.修改frameworks\cocos2d-x\cocos目录下的 Android.mk
添加一句LOCAL_CFLAGS :=-DCOCOS2D_DEBUG=1 -DANDROID 这样就定义了cpp中的 ANDROID 宏,相当于#define ANDROID
LOCAL_CFLAGS :=-DCOCOS2D_DEBUG=1 -DANDROID
LOCAL_SRC_FILES := \
cocos2d.cpp \
2d/CCAction.cpp \
2d/CCActionCamera.cpp \
2d/CCActionCatmullRom.cpp \
2d/CCActionEase.cpp \
2d/CCActionGrid.cpp \