2013-03-10 59 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 
相關問題