Object-oriented programming framework Lua learning FreeGame extend the framework to learn object-oriented programming Lua to do is touch the spirit of FreeGame

The first step

Download and install Lua compiler and build environment:

Picture 1:

 

Picture 2:

 

 

Photo 3:

 

 

Picture 4:

 

 

Picture 5:

 

 

 

 

 

 

 

Part of the code:

 

ActionDao={ };

function ActionDao:new(...)
    The location = {};
    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 ( "not found:" .. (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;




In other parts of the cloud Baidu plate:
 

Link: https: //pan.baidu.com/s/1W31oUoh5zMGJMPja32PqCQ
extraction code: 84aj

 

 

Guess you like

Origin www.cnblogs.com/xulang/p/12504840.html