Lua 面向对象编程学习 FreeGame 的框架学习 以面向对象 思想 做Lua的编程 FreeGame 为 触动精灵 的 扩展框架

首先第一步

编译器的下载 与安装 以及 Lua 环境的搭建:

图片1:

 

图片2:

 

 

图片3:

 

 

图片4:

 

 

图片5:

 

 

 

 

 

 

 

部分代码:

 

ActionDao={ };

function ActionDao:new(...)
    local o={};
    setmetatable(o,self);
    self.__index=self;
    self.__tostring=function(o)
        local str="";
        for k,v in pairs(o.colors) do
            str=str..v.name..","
        end
        return "Action:"..str;
    end
    o.colors= {...};
    o.fragment={};
    o.after=nil;
    return o;
end

function ActionDao:run()

    local p=nil;
    for k,v in pairs(self.colors) do
        p = v:getPoints();
        if not p then
            print("没有找到:"..(v.name));
            break;
        end
    end
    if p and #self.fragment>0 then
        for k,f in pairs(self.fragment) do
            f:run(self,p);
            if self.after~=nil and self.after()==false then
                return true;
            end
        end
    end
end

function ActionDao:click(...)
    self.fragment[#self.fragment+1]=Clickf:new(...);
    return self;
end

function ActionDao:slidf(...)
    self.fragment[#self.fragment+1]=Slidf:new(...);
    return self;
end

function ActionDao:sleep(...)
    self.fragment[#self.fragment+1]=Sleep:new(...);
    return self;
end

function ActionDao:afterfc(func)
    self.after=func;
    return self;
end


return ActionDao;




其它部分在百度云盘:
 

链接:https://pan.baidu.com/s/1W31oUoh5zMGJMPja32PqCQ
提取码:84aj

 

 

posted @ 2020-03-16 16:43  徐朗  阅读(1420)  评论(0编辑  收藏  举报