2013-03-10 57 views
0

我有这样的好车班尚未:如何在Corona(Lua)中创建输入框?

function scene:enterScene(event) 
    local group = self.view 
    physics.start(); 
    local car1=pcar.new(200,200); 

end 

它工作正常,exept,它给了我一个错误 “断言失败” 的

> getOrCreateTable 
> addEventListener 
> addEventListener 
> Runtime:addEventListener("enterFrame",self.main_frame(self)); 

local car={}; 
local car_mt = { __index=car }; 

local this; 
function car.new(_x, _y) 
    local ncar= 
    { 
     img=display.newImageRect("test_car.png",50,120,true); 
     x=0; 
     y=0; 
     main_frame=function(self) 
      self.img.x=self.x; 
      self.img.y=self.y; 
     end 
    } 
    function ncar:set() 
     self.x=_x; 
     self.y=_y; 
     Runtime:addEventListener("enterFrame",self.main_frame(self)); 
    end 
    ncar:set(); 
    return setmetatable(ncar,car_mt); 
end 
return car; 

我通过把它

在显示器上,一切似乎都没问题。怎么了?

回答

1

终于解决了这个问题:

main_frame=function(self) 
     return function(event) 
      self.img.x=self.x; 
      self.img.y=self.y; 
     end 
    end 
相关问题