2015年9月18日

摘要: function cc.exports.VectorRotateByAngle(vector,angle)--计算向量旋转后的向量,angle:正数逆时针,负输顺时针 angle = angle*math.pi/180 local sinAngle = math.sin(angle) loca... 阅读全文
posted @ 2015-09-18 11:59 HemJohn 阅读(604) 评论(0) 推荐(0) 编辑
摘要: function cc.exports.findValueByTbl(tbl,key)--递归方法,用于查找tbl中对应的键值 for k,v in pairs(tbl) do if k == key then if type(tbl[i])=="table" then--如果是t... 阅读全文
posted @ 2015-09-18 11:55 HemJohn 阅读(701) 评论(0) 推荐(0) 编辑
摘要: -- 参数:待分割的字符串,分割字符 -- 返回:子串表.(含有空串) function split(str, split_char) local sub_str_tab = {} while true do local pos = string.find(str, split_char) if n 阅读全文
posted @ 2015-09-18 00:05 HemJohn 阅读(5924) 评论(0) 推荐(0) 编辑
摘要: 在2d游戏中,经常会出现闪退或者报错的问题,通过写文本,将日志文件发送给服务端,让后端人员进行分析。通过lua打印日志在文本文件中:local file = io.open(cc.FileUtils:getInstance():getWritablePath().."myLog","w")--myL... 阅读全文
posted @ 2015-09-18 00:01 HemJohn 阅读(818) 评论(0) 推荐(0) 编辑

导航