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

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章