runtime event crash

I'm trying to figure out how to remove the follow event:

1
2
3
4
function clean ( event )
        Runtime:removeEventListener( "enterFrame", moveCamerax )
        Runtime:removeEventListener( "enterFrame", moveCameray )
end

Remove it when you are no longer using it.

Ie when changing back to the menu or such

Just before your changeScene ie

Runtime:removeEventListener( "enterFrame", moveCamerax )
Runtime:removeEventListener( "enterFrame", moveCameray )
director:changeScene("NextScene")

Actually, it wasn't a runtime error... For some reason Director doesn't like changing scenes without a transition effect unless it's the main.lua file.
I switched the code from this:

1
director:changeScene("levelSelect")

It may be because without a transition it changes too fast?

Are you using the latest Director (1.2)? Where I think this has been fixed (see 3 below).

Release Info for 1.2 follows, taken from this thread:

http://developer.anscamobile.com/forum/2011/02/02/any-idea-when-v12-might-come-out

All the major updates were at the memory management and cleaning scenes.

1 - Now you don't need to modify Director to use the clean function, Director will search for it and if it find then will execute it.

2 - Cleaning scenes are divided in 3 steps:
2.1 - Execute the clean() function if it exists
2.2 - Remove all display objects inserted into the localGroup
2.3 - Unload the module and call the garbage collector

3 - I added a "safe time delay" to start transitions without crashing.

4 - You can change the effects time and safe delay via programming.

5 - There are 3 new transitions on changeScene:
5.1 - moveFromTop
5.2 - moveFromBottom
5.3 - crossfade

6 - A lot of people asked me about changing scenes like a book. I tryed to do it on this version but it is very hard to do. So, I put on the sample a little slider to see how to use moveFromLeft and moveFromRight to feel like a book.

7 - All the files on the sample are better structured and have the initVars() function to show how to start your variables values and use it on a pause or restart function.

8 - There is a boolean variable to prevent change scenes while it's still changing a scene.

I'm using version 1.2 but I think your right about the scene change happening to fast with no transition effect. I looked through the code for director (1.2) and found this code applies to a scene change with no transition effect:

1
2
3
4
5
6
7
8
-----------------------------------
-- EFFECT: None
-----------------------------------
        
else
   timer.performWithDelay( 0, fxEnded )
   loadScene (newScene)
end

I had a similar issue... I don't specify an effect in my transitions and, on occasion, my app would crash during a transition between two screens (modules). Now to be fair... I would have to work at crashing it by rapidly changing back and forth between screens but it would happen. I added the safeDelay time to the code in the above post and it greatly reduced the crashing. I then doubled the time and it appears to have eliminated all crashing. Of course this may all be coincidence but the addition of time appears to have had a beneficial affect.

Just as a followup... I wasn't using the clean function correctly which created a race condition that was helped by the delay. Of course, correctly using clean allowed me to remove the delay and still have perfect operation.

The only way you can guarantee no crashing between rapid screen transitions (ie tapping menu then back as fast as possible). is to remove your active listeners on touch then delay adding your touch listeners for the next scene by 3 times the fx delay.

I had to do that, and it removed all crashing. And the timing is perfect so as soon as the scene has actually finished transitioning the buttons are usuable, but not before.

That fixed the issue for me

infuseddreams , would u please clarify what you wrote, I got confused,

I have more than one add listener so how can I make all of them 3 times of fx delay ?

views:1653 update:2011/10/13 9:25:17
corona forums © 2003-2011