Hey Corona-ites,
I’m beating my head against the wall trying to figure this out. I have a simple test case where I’m using director to switch to my play level. On that level, I have an update function that prints, and then a Runtime event listener for that update function. Everything works great until I try to switch back to my menu. I’m using a button with a scene changing/cleaning function. In that function, I am removing the runtime listener. The problem is that the listener isn’t being removed, and when I switch back to the menu, the printing is still happening. Any ideas? I’ll post some code below without all the director business.
Thanks!
–Kev
[code]
–Hide status bar
display.setStatusBar(display.HiddenStatusBar);
local function changeSceneClean()
print(“Cleaning Scene”)
Runtime:removeEventListener(“enterFrame”, update)
cancelAllTransitions()
cancelAllTimers()
director:changeScene (“menu”, “overFromTop”)
end
local replayButton = display.newRect(0, 0, 50, 50)
replayButton.x = _W*0.085;
replayButton.y = _H*0.9;
replayButton.alpha = 0.5;
localGroup:insert(replayButton)
– Replay Button function
local function pressButton (event)
if event.phase == “began” then
replayButton.alpha = 1.0
transitionStash.newTransition=transition.to(event.target, {time=50, xScale=1.25, yScale=1.25})
end
if event.phase == “ended” then
replayButton.alpha = 0.5
changeSceneClean()
end
end
replayButton:addEventListener (“touch”, pressButton)
local function update(event)
print(“Still updating”)
end
Runtime:addEventListener(“enterFrame”, update)
[/code] [import]uid: 70550 topic_id: 27429 reply_id: 327429[/import]