Corona SDK和lua中事件监听器的问题

我在我的程序中创建事件时遇到了问题。当我尝试使用以下系统设置运行它时,我会收到错误“尝试调用方法‘addEventListener(一个空值)’”。我要实现的效果是OtherObject文件发送一个信号,即事件,到Object文件,告诉特定的实例它已完成OtherObject文件中的某些任务。非常感谢任何帮助或指导,让我走上正确的道路。

Object File

Object = {};

ObjectMeta = {__index = Object};

function Object:onTrigger()
   --事件被触发
end

function Object.new(args)
    Obj = {};
    Obj.sprite = display.newImage("Picture.png");
    Object.someObject = OtherObject.new(args);
    Object.someObject.owner = Object;
    Object:addEventListener("onTriggered", Obj);
    return setmetatable(Obj,ObjectMeta );
end

return Object;

OtherObject File

OtherObject = {};

OtherObjectMeta = {__index = OtherObject};

function OtherObject.new(args)
    Obj = {};
    Obj.sprite = display.newRect(0,0,3,7);
    Obj.ObjectImAttachedTo =nil;
    return setmetatable(Obj,OtherObjectMeta );
end
function OtherObject:doSomething()
    self.ObjectImAttachedTo:dispatchEvent( {name = "triggered"} );
end
return OtherObject;
点赞
用户1847592
用户1847592
本地对象 = {}

本地对象元表 = {__index = 本地对象}

function 本地对象:触发事件(事件)
   --事件被触发
end

function 本地对象.新建(参数)
    本地对象实例 = {}
    本地对象实例.其他对象 = 其他对象.新建(参数)
    本地对象实例.其他对象被附加到的对象 = 本地对象实例
    setmetatable(本地对象实例, 本地对象元表)
    Runtime:addEventListener("触发事件", 本地对象实例)
    return 本地对象实例
end

return 本地对象
2013-05-09 08:00:13