【问题标题】:How to create enterframe in Corona (Lua)?如何在 Corona (Lua) 中创建 enterframe?
【发布时间】:2013-03-10 10:35:50
【问题描述】:

我还有这个不错的汽车课:

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;

我叫它:

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));

在显示器上一切似乎都很好。怎么了?

【问题讨论】:

    标签: lua coronasdk


    【解决方案1】:

    终于这样解决了:

        main_frame=function(self)
            return function(event)
                self.img.x=self.x;
                self.img.y=self.y;
            end
        end
    

    【讨论】:

      猜你喜欢
      • 2013-06-11
      • 1970-01-01
      • 1970-01-01
      • 2011-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多