Scene does not hide like it should

Hi guys,

I’ve been asked to re-write my code to make it more readable and add some print statements so it’d be easier to determine where the problem is at. So I started from scratch again but I’m still getting some weird behavior.

Allow me to explain:

Everything works fine when I play through level 1 for the first time. When you’ve won the level you can choose the play the level again in a level selection screen. But when I open level 1 again, things aren’t what they are supposed to be. Because I’m getting an error called “ERROR: /Volumes/USB Bram Va/Game/level1.lua:332: physics.start() must be called before physics.stop()”. But I’m perfectly able to play the game again without having issues except that error. The problem starts occurring after I close level 1 for the second time and also when I re-open the level again. Because I’m getting tons of “ERROR: /Volumes/USB Bram Va/Game/level1.lua:332: physics.start() must be called before physics.stop()” errors when the level is closed. 

I feel like it is weird because I clearly start and top my physics when the game starts and ends.

Any suggestion would be a step in the right direction so please, take a guess :smiley:

Thanks in advance

Bram

Anyone please? iI’ll be happy with every suggestion :slight_smile:

No one seems to have a solution. I’ve re-writen my code for the 3 time and I’m still getting this weird behavior. I also tried reinstalling corona SDK but without any luck. I just don’t get how this error: 

“ERROR: /Volumes/USB Bram Va/Game/level1.lua:332: physics.start() must be called before physics.stop()”

can occur at the beginning of my scene. How does corona start reading at line 332 in the hide:scene function?

​I’ve tried everything in my league to fix this issue, but I just can’t find a solution.

I’ve also noticed that my spawning gets executed 2 times instead of 1 when you play for the second time and 3 times when you play for the third time and so on…

Could someone at least say that they also have no clue why this is happening so I could stop searching and just stop with this complete project? :confused:

I’m desperate :frowning:

Have a good day

Bram…

have you tried putting physic.stop inside win() function

​and of course removing physics.stop from hide scene 

Hi Scott,

so I tried that and it seems to be working now for the second time that I open the level, but the problem remains for if u play the level again for more times. I also tried putting my cancel.timers in the win function because my timers also seemed to not cancel. This also didn’t work. It feels like an extra timer is added automatically every time that I re-open the level.

Do you see anything else odd about my code?

Kind regards

Bram

Try adding

composer.recycleOnSceneChange = true

Scot, you are my hero of the day!

This totally fixed it. My last and final question, the strange behaviour. 

Was it my code or was it some sort of problem with corona? I’d like to know for the feature :slight_smile:

Just want to tell you one more time how much I appreciate your help!

have a wonderful day

Bram

Nether, composer just mainly handles images and not physics.

When you go another scene the previous scene is still loaded.

Anyone please? iI’ll be happy with every suggestion :slight_smile:

No one seems to have a solution. I’ve re-writen my code for the 3 time and I’m still getting this weird behavior. I also tried reinstalling corona SDK but without any luck. I just don’t get how this error: 

“ERROR: /Volumes/USB Bram Va/Game/level1.lua:332: physics.start() must be called before physics.stop()”

can occur at the beginning of my scene. How does corona start reading at line 332 in the hide:scene function?

​I’ve tried everything in my league to fix this issue, but I just can’t find a solution.

I’ve also noticed that my spawning gets executed 2 times instead of 1 when you play for the second time and 3 times when you play for the third time and so on…

Could someone at least say that they also have no clue why this is happening so I could stop searching and just stop with this complete project? :confused:

I’m desperate :frowning:

Have a good day

Bram…

have you tried putting physic.stop inside win() function

​and of course removing physics.stop from hide scene 

Hi Scott,

so I tried that and it seems to be working now for the second time that I open the level, but the problem remains for if u play the level again for more times. I also tried putting my cancel.timers in the win function because my timers also seemed to not cancel. This also didn’t work. It feels like an extra timer is added automatically every time that I re-open the level.

Do you see anything else odd about my code?

Kind regards

Bram

Try adding

composer.recycleOnSceneChange = true

Scot, you are my hero of the day!

This totally fixed it. My last and final question, the strange behaviour. 

Was it my code or was it some sort of problem with corona? I’d like to know for the feature :slight_smile:

Just want to tell you one more time how much I appreciate your help!

have a wonderful day

Bram

Nether, composer just mainly handles images and not physics.

When you go another scene the previous scene is still loaded.