今天遇到一个问题,用cocos2d创建了一个lua项目,发布出release版本的时候,在命令行无法显示print消息,最后将用到print的地方加入realse_pritnt,这样,在命令行可显示所有的print消息
我使用了babelua,所以写法是这样的
function cc.exports.babe_tostring(...)
local num = select("#",...);
local args = {...};
local outs = {};
for i = 1, num do
if i > 1 then
outs[#outs+1] = "\t";
end
outs[#outs+1] = tostring(args[i]);
end
return table.concat(outs);
end
local babe_print = print;
local babe_output = function(t, ...)
local targetPlatform = cc.Application:getInstance():getTargetPlatform()
if (cc.PLATFORM_OS_WINDOWS == targetPlatform) then
release_print(t,...)
end
if decoda_output ~= nil then
local str = babe_tostring(...);
decoda_output(str);
end
end
print = babe_output;