在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
记得把extern.lua拷贝到你的资源目录,这里要用到 require "extern" MyLayer = class("MyLayer", function(fileName) return CCSprite:create(fileName) end ) function MyLayer.CreateWithFile(fileName) local o = MyLayer.new(fileName) o.m_nA = 0 return o end function MyLayer:setVisible(flag) getmetatable(self).setVisible(self,flag) self.m_nA = self.m_nA + 5 end local a = MyLayer.CreateWithFile("dog.png") print(a.m_nA) local b = MyLayer.CreateWithFile("dog.png") b:setVisible(true) print(b.m_nA)
顺道记一下lua里有变长参数的函数用法 function Add(...) local t = {...} for i,v ipairs(t) do print(i,v) end end
|
请发表评论