上一页 1 ··· 7 8 9 10 11 12 下一页

2015年9月26日

摘要: unity中自带两个回调函数:voidOnBecameVisible()//当物体可见时,回调一次。voidOnBecameInvisible()//当物体不可见时,回调一次。在untiy编辑器中,无论调试窗口还是编辑窗口,只要能看到物体,OnBecameVisible都会被调用 阅读全文
posted @ 2015-09-26 00:07 HemJohn 阅读(2400) 评论(0) 推荐(0) 编辑

2015年9月25日

摘要: 使用unity3d对于一些可视化强迫者来说,是一个不错的选择,但unity3d没有cocos2d的action管理机制,比如cocos2dx的CCMoveTo,CCScale等action,所以笔者通过封装action管理来实现类似cocos2dx的actionmanager。首先需要写一个Acti... 阅读全文
posted @ 2015-09-25 22:45 HemJohn 阅读(228) 评论(0) 推荐(0) 编辑

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) 编辑

2015年9月17日

摘要: function cc.exports.VerticalVector(vec)--求出两个垂直向量 local result = {} result[1] = cc.p(vec.y/vec.x,-1)--向下方向 result[2] = cc.p(-vec.y/vec.x,1)--向上方向 ... 阅读全文
posted @ 2015-09-17 17:36 HemJohn 阅读(1589) 评论(0) 推荐(0) 编辑
摘要: cc.exports.LineCollideRect(startLine,endLine,rect)--向量与矩形检测碰撞 --获取矩形的四个顶点位置 local p = {cc.p(rect.x,rect.y),cc.p(rect.x + rect.width,rect.y),cc.p(rec... 阅读全文
posted @ 2015-09-17 17:27 HemJohn 阅读(707) 评论(0) 推荐(0) 编辑
摘要: 在之前,笔者写过一编博客,通过lua在加载场景加载spineAnimation动画精灵,保存在table中,然后在游戏中创建动画精灵时,提取加载好的spineAnimaiton中的spSkeletonData来创建spineAnimation,但后来笔者发现重复创建spineAnimation时,全... 阅读全文
posted @ 2015-09-17 12:30 HemJohn 阅读(715) 评论(0) 推荐(0) 编辑
摘要: 首先要创建一个layer,设置该层为可触摸layer:setTouchEnabled(true)注册触摸事件local listener = cc.EventListenerTouchOneByOne:create()listener:setSwallowTouches(true)listener:... 阅读全文
posted @ 2015-09-17 12:04 HemJohn 阅读(979) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 下一页

导航