lua继承c++类
local MyScrollView =class("MyScrollView",function () local scrollview = cc.ScrollView:create() -- _minScale=scrollview._minScale -- _maxScale=scrollview._maxScale return scrollview end) function MyScrollView:create() --自定义构造函数 local myScrollView = MyScrollView:new() return myScrollView end function MyScrollView:create(size) local myScrollView = MyScrollView:new() myScrollView:initWithViewSize(size) return myScrollView end function MyScrollView:create(size,minScale,maxScale) local myScrollView = MyScrollView:new() myScrollView:initWithViewSize(size) myScrollView._minScale = minScale myScrollView._maxScale = maxScale -- myScrollView:setMinScale(minScale) -- myScrollView:setMaxScale(maxScale) return myScrollView end function MyScrollView:setMinScale(scale) -- getmetatable(self)._minScale=scale MyScrollView._minScale = scale end function MyScrollView:setMaxScale(scale) -- getmetatable(self)._maxScale=scale MyScrollView._maxScale = scale end
只能根据父类有的函数来实现类
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。