. The difference: and lua

. The difference: and lua

  • In the first use lua ":": defined functions defined function will automatically pass a variable named self, and this variable is implicit, self, like c ++ in this, that the current pointer to the object. "" There are no self.
function  class:func2( )  end
function  class.func1(self)  end
  --这时候这两个函数等价
  
function MainScene:ctor()
    self:ceshi(1,2,3)
end
function MainScene:ceshi(a,b,c)
    print(a,b,c)
end
输出:1 2 3

Guess you like

Origin www.cnblogs.com/frankltf/p/12171859.html