Search code examples
timerluasdkduplicatescoronasdk

Corona / Lua / frustrating timer multiplication


I am in the process of building a mobile game with Corona SDK, which is based on Lua. Until now i didn't need any help but this time I can't seem to find the cause, and I've been searching for it for hours.

It's one of those timer problems, where, after leaving, removing, and revisiting the scene, items that are spawned within a loop just multiply themselves every relaunch. More specificly, everytime a "forbidden" collision happens, which leads to the relaunch, according to my onCollision function.

What I already corrected after hours of strenuous research :

--the code inside the onCollision function is now inside the "began" phase, so that can't cause the multiplication

--the scene phases are also correctly used

--transitions and timers are all canceled right before the relaunch

Since the code would be too long for you to look through, I'd rather ask for some hints :

What do you have in mind can cause such problems, besides what I already mentioned.

I appreciate every answer! Thanks alot.


Solution

  • The above comments are valid, it is going to be hard to diagnose the problem without being able to look at the code.

    In the past, I have found it very helpful to name all my objects when dealing with collisions, so when a collision happens I know what objects caused it and it is very helpful for debugging purposes.

    It looks like you have an issue with how you are starting the scene and deallocating resources when the scene ends. You may want to start/stop physics when the scene leaves and comes back, but without code I can't give a concrete answer.