WORD OF CAUTION ABOUT EVENT LISTENERS

I was trying to find a bug for 3 days. I rebuilt my game to use the new Composer library and I decided to make the smaller composer scenes  have all the variables and functions  in a table… ugh but then I decided to only put the variables in a table but NOT the functions.

When I played my game and I would move through the scenes to the level editor and back… timer.performWithDelay would be off – causing my game particles and transitions to seemingly slow down… but not the framerate. The one shot particle emitters would fire two times… then three times, four times, five times. each time I went back through the scenes … and the transitions would seem jerky each time… ANYWAY It was driving me crazy. I thought maybe it was a bug in composer and maybe I should go back to storyboard…!

To make a long story short I made a particle just to trace down this bug so I could tell how many times the one shot particle Emitters would fire. I traced the bug down to ONE scene in composer. Each time I loaded this scene it would increment the problem.

Anyway,  I was still passing a  function inside a table to  remove event listener… I had removed this function from the table… so I was a nil value… but it would still except a nil value so I didn’t know this was happening!!

  Runtime:removeEventListener( "enterFrame", LevelSelectScene.onEveryFrame)

Just a word of caution if you experience problems like mine… the culprit could very well be that you did not properly remove an even listener… thanks!