Runtime error : attempt to index field 'contentBounds' (a nil value)

Hi, 

I have some scenes in my project that each of them are a seperate game. They works fine , but when i close one of them with 

composer.removeScene( "scene name")

and open another one in their menu by 

composer.gotoScene( "another scene name" , options )

on the above line an error occured :

Runtime error ?:0: attempt to index field 'contentBounds' (a nil value) stack traceback: ?: in function '\_saveSceneAndHide' ?: in function 'gotoScene' ?: in function \<?:221\>

By restart the simulator, all of scenes works fine on first run.

but, when run one of them, then remove it and go to the other one without restart corona simulator, makes the above error. 

The other note is when i comment the removeScene line of a scene (i.e does not remove that scene) and then execute goToScene for another one, it works fine!

Any idea?

Thanks

You didn’t show any code of how you are using the removeScene but my guess is you are calling it in the wrong place. You would normally remove the previous scene in the scene:Show of the next scene. Check out the Composer sample included in the CoronaSDK for an example of how it’s used.

Thanks, but after a game, i have another scene to handle the exit process of that game, for example two buttons in that scene and if touch the YES button :

if ( minigame\_name == "1") then composer.removeScene( "games.game1.scene\_game") end composer.hideOverlay( "fade",100 )

Then the app returns to the games menu , i choose another game and call another goToScene for second game : 

elseif (game\_id == 2) then local composer = require("composer") local options = { time = 500, isModal = true } composer.gotoScene( "games.game2.game" , options ) end&nbsp;

According to above description, the remove process of the previous scene takes in ExitScene (third party scene) and the process of calling another scene done in GameChooseMenu.

Normally you would only require composer at the top of the scene file and not inside a block like the elseif. What happens if you remove that line and just have it as the very first line of your module?

Rob

Thanks, I did this. The problem persists.

this error still exist , any help or hint to solve it?

Are there more errors in your console log?

Can you post unmodified code that might be causing this>

Rob

You didn’t show any code of how you are using the removeScene but my guess is you are calling it in the wrong place. You would normally remove the previous scene in the scene:Show of the next scene. Check out the Composer sample included in the CoronaSDK for an example of how it’s used.

Thanks, but after a game, i have another scene to handle the exit process of that game, for example two buttons in that scene and if touch the YES button :

if ( minigame\_name == "1") then composer.removeScene( "games.game1.scene\_game") end composer.hideOverlay( "fade",100 )

Then the app returns to the games menu , i choose another game and call another goToScene for second game : 

elseif (game\_id == 2) then local composer = require("composer") local options = { time = 500, isModal = true } composer.gotoScene( "games.game2.game" , options ) end&nbsp;

According to above description, the remove process of the previous scene takes in ExitScene (third party scene) and the process of calling another scene done in GameChooseMenu.

Normally you would only require composer at the top of the scene file and not inside a block like the elseif. What happens if you remove that line and just have it as the very first line of your module?

Rob

Thanks, I did this. The problem persists.

this error still exist , any help or hint to solve it?

Are there more errors in your console log?

Can you post unmodified code that might be causing this>

Rob