Hi,
I used the following functions to go through levels of my game. The removeEventListener s do not work in endGame(event). Can anyone help me with this?
I was wondering if there is a way to check if a listener has been removed from the Runtime object.
local function startGame()
Runtime:addEventListener( "enterFrame", move );
Runtime:addEventListener( "enterFrame", shooting );
Runtime:addEventListener( "touch", targetTap );
Runtime:addEventListener( "enterFrame", platformAppear);
Runtime:addEventListener( "enterFrame", fgAppear);
Runtime:addEventListener( "enterFrame", noPhyFGAppear);
Runtime:addEventListener( "enterFrame", zeroGroundAppear);
Runtime:addEventListener( "enterFrame", enemyAppear );
Runtime:addEventListener( "enterFrame", collectableAppear );
Runtime:addEventListener( "enterFrame", checkStatus );
end
local function endGame()
Runtime:removeEventListener( "enterFrame", move );
Runtime:removeEventListener( "enterFrame", shooting );
Runtime:removeEventListener( "touch", targetTap );
Runtime:removeEventListener( "enterFrame", platformAppear);
Runtime:removeEventListener( "enterFrame", fgAppear);
Runtime:removeEventListener( "enterFrame", noPhyFGAppear);
Runtime:removeEventListener( "enterFrame", zeroGroundAppear);
Runtime:removeEventListener( "enterFrame", enemyAppear );
Runtime:removeEventListener( "enterFrame", collectableAppear );
end
local function checkStatus(event)
if isStageFinished == true then
isStageFinished=false
endGame() -- remove eventlisteners
currentStage = currentStage+1
if currentLevel \> 2 and currentLevel ~= 5 and currentStage == 5 then
-- level 3 and 4 don't have stage 5!
currentStage = 6;
end
if currentStage \> 6 then
currentStage = 1;
currentLevel = currentLevel+1;
if currentLevel \> 5 then
isChampFinished = true
end
end
main()
end
end
Cheers,
Arash
[import]uid: 80320 topic_id: 28825 reply_id: 328825[/import]