This is not a bug.
There are 2 ways to listen for a custom event: TABLE (OBJECT) listeners and FUNCTION listeners, and I think you are confusing/mixing the syntax. Very easy mistake to make.
My suggestion is to learn one syntax well, then learn the second one. And I would start with TABLE (OBJECT) syntax, because it will help you avoid potential confusion about variable scope issues that could occur with the function syntax.
[lua]-- THIS EXAMPLE USES TABLE (OBJECT) SYNTAX
– Using table/object syntax, the listener is your circle object (renamed
–to help illustrate)
local myListenerObj = display.newCircle( 100, 100, 20 )
– You defined a function to be called. But it was a local function.
– Instead, you need to make this function belong to the listener obj as
– a method of that object. Originally, you called this “myEventListener”
– which can add to your confusion. Instead, we will now call this
– “myHandlerFunc” and attach it as a method of myListenerObj
– WAS: local function myEventListener()
function myListenerObj:myHandlerFunc()
print(“my event occured”)
end
– Now tell our circle to listen for events called “myHandlerFunc”
myListenerObj:addEventListener(“myHandlerFunc”, myListenerObj)
– Now we wait 1 second and trigger the dispatch event method
timer.performWithDelay ( 1000, function()
myListenerObj:dispatchEvent( {name=“myHandlerFunc”} )
end, 1)[/lua]
[import]uid: 10818 topic_id: 14512 reply_id: 56435[/import]