Composer not switching scene memory contexts properly

This is some very strange behavior I’m seeing. 

timer.performWithDelay() is calling a function in the previous scene that has the same name as a function in the _current _scene.

Repro steps:

  1. Create two scenes, scene  A (the default scene) and scene  B
  2. Add a lua function that has the same name to both scenes
  3. In scene  A , use timer.performWithDelay() in show() to call the function at some interval with infinite iterations. Be sure to remove the timer in hide().
  4. In scene  B , use timer.performWithDelay() in show() to call scene  B’s version of the function at some interval with infinite iterations.
  5. When scene  B tries to call the function,  it calls the function in scene A   instead of calling its own version. It seems like composer hasn’t switched memory contexts yet or something.

Is this a bug (know or not), or the intended behavior of composer?

Composer doesn’t clean up timers for you, so it’s possible that the timer started in scene A is still running, and therefore calling the function at it’s completion. Have you added print statements to determine which _ specific _ function is being called when a timer is completed?

Are both functions with the same name or global?

Are you cancelling the timer in the “will” phase or the “did” phase of hide?

Rob

Composer doesn’t clean up timers for you, so it’s possible that the timer started in scene A is still running, and therefore calling the function at it’s completion. Have you added print statements to determine which _ specific _ function is being called when a timer is completed?

Are both functions with the same name or global?

Are you cancelling the timer in the “will” phase or the “did” phase of hide?

Rob