![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
lua基础
cocos_wht
这个作者很懒,什么都没留下…
展开
-
lua实现类与继承,多继承
--采用闭包方式实现类的概念----eg: 创建一个 Person类local function Person() local tab = { high = 0, wight = 0, } function tab:PerMessage() print(self.high,self.wight); end return function() return原创 2016-12-12 10:22:38 · 2205 阅读 · 0 评论 -
lua实现快排,选择排序--与c++一样
function sortTable(table_array,lift_id,right_id)--lua实现快速排序if(lift_id local int_X = table_array[lift_id]--标记中间点local length = right_id--记录长度local start_id = lift_idwhile lift_id w原创 2016-11-21 10:27:45 · 668 阅读 · 0 评论 -
用闭包实现ipairs
local table1 = {2,3,4,5,6}print("the first print:");for k,v in ipairs(table1) do print(k,v)endfunction my_ipars(table) local key = 0 return function() key = key+1 return key,table[key] e原创 2016-12-07 17:38:50 · 310 阅读 · 0 评论