I coded my in-game menu as a module, so I can call my menu on any level. In this menu I have a button to quit to title screen. The problem comes when I try to remove the runtime event listener located outside of my menu module. The event listener is part of my level.lua file. When I call the Runtime:removeEventListener("enterFrame", main)
, it doesn't remove the event listener. Is it possible to remove the event listener in this way or can it only be removed from inside the level.lua file? I would greatly appreciate any help, thank you.
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
Runtime Listener Question
You could wrap the remove listener call inside its own function and call the function from the other file.
I will give it a try. I assumed since Runtime is global that I would be able to remove it from an external module without a problem.
Ok I tried what you suggested and it the function fires properly, but it refuses to remove the listener. I inserted print statements and verified that the function is working. I'm really stumped why I cannot remove this event listener. Any ideas??
Just a thought: is it possible that you are programmatically creating more than one Runtime/enterFrame listener? Like each time you create a level you duplicate the listener? If so you might only be removing one instance of the listener.
Let's say you finish level one and advance to level two without removing the listener. Then in level two you call the menu. This call removes the listener initiated in level two, but the listener in level one remains.
May not be what is going on in your app, but it is all I can think of at the moment.
Thanks for your suggestions. But I am positive I only have one Runtime event listener. I can verify that I can remove the event listener by calling the removeEventListener from within the level.lua file. But I am unable to remove it by wrapping it in a function within the level.lua and calling that function from my menu.lua. Pretty weird because I assumed that it would work. I'm not even sure if what I am trying to do is possible. I'm hoping someone who knows the answer comes across my topic!!
Ok I figured it out. I was able to use your method. I just had to enter the function underneath my Runtime enterFrame function in my level file. Jeez what a headache!! Live and learn I guess :)
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
Want to be on our upcoming Corona SDK video?
Lua code snippets?
Application failed to pass Apple's validation tests. Please help!
android.hardware.screen.portrait
Corona remote 1.2: run time error
New Showcase on Ansca's Website is EPIC!
Scamps
Effect Like This? (video link incl.)
director transitions on android don't work