Composer API scene:hide() problem

Hi,

I have a problem where scene:hide() seems to be called when the lua file reloads.

In this case the whole project works fine the first time through.

When the player character collides with the enemy, the user is taken back to the menu screen.

But when they tap the start button to restart, they go back to scene_game.lua, and scene:hide() runs as soon as the file loads. Probably I’m not clearing something correctly when the first collision occurs and the user is taken back to scene_menu.lua… but if anyone can help out I’d really appreciate it!

I also have a scene_restart.lua currently not in use but included with the files. The idea here was that when the collision occurs, the user is briefly taken to scene_restart.lua where the composer.removeScene() method is called on scene_game.lua - but this didn’t work either.

Link to the project - https://www.dropbox.com/s/dhhu1s09pkk6q0n/Composer%20Tiny%20Game.zip

Thanks in advance,

Mark

When I did the blog post on reloading scenes for Storyboard (http://coronalabs.com/blog/2013/08/20/tutorial-reloading-storyboard-scenes/) I highly recommend using a cut scene.  Give your players a place to go letting them know they lost the level and are restarting.  This lets  you goto the scene fresh by removing the scene making resets easy.  Almost every game since Space Invaders has used cut scenes.

If you insist on not using a cut scene, then be aware that calling composer.gotoScene() to reload the scene is going to call hide() and show() as part of it’s processing.  There is a parameter you can pass to gotoScene() that will have it dispose of it’s view in the process.  The whole process of deleting the onscene view and recreating it seems weird to me. 

Rob

Thanks Rob.

I’ve implemented a cut-scene lua file that calls removeScene() using the method described in your video (but using Composer not Storyboard).

The problem is that whilst the scene:create() method is now called on the lua files that have been removed, the part up the top (the forward declarations etc) are not being run again. In other words the removeScene method seems to not quite fully removing them. 

I’m fairly sure I’m using the composer.removeScene() method correctly. I’m setting the second parameter to ‘false’ so that the lua files are removed and not just recycled.

The call to composer.removeScene() occurs in the ‘scene_remove.lua’ file which is the equivalent of the ‘reloading.lua’ file in your video.

I have attached the project - https://www.dropbox.com/s/061ceo16iolwqa5/Composer%20Tiny%20Game%202.zip

Thanks again in advance,

Mark

I have the same issue as Mark, I remove the scene and go back to the menu, all fine and dandy… but if I then start the game again I will get an error because the things I have placed outside of the listener functions does not get initiated… 

so it does not seem to load the scene/file from scratch again… like it did with storyboard and when you purged things.

There seems to be a bug in removeScene() not unloading the scene. Engineering is aware of it.  I’ll prod them on it too.

Rob

awesome, hope it gets fixed soon :slight_smile:

Thanks for your replies - looking forward to the issue being fixed soon too :slight_smile:

When I did the blog post on reloading scenes for Storyboard (http://coronalabs.com/blog/2013/08/20/tutorial-reloading-storyboard-scenes/) I highly recommend using a cut scene.  Give your players a place to go letting them know they lost the level and are restarting.  This lets  you goto the scene fresh by removing the scene making resets easy.  Almost every game since Space Invaders has used cut scenes.

If you insist on not using a cut scene, then be aware that calling composer.gotoScene() to reload the scene is going to call hide() and show() as part of it’s processing.  There is a parameter you can pass to gotoScene() that will have it dispose of it’s view in the process.  The whole process of deleting the onscene view and recreating it seems weird to me. 

Rob

Thanks Rob.

I’ve implemented a cut-scene lua file that calls removeScene() using the method described in your video (but using Composer not Storyboard).

The problem is that whilst the scene:create() method is now called on the lua files that have been removed, the part up the top (the forward declarations etc) are not being run again. In other words the removeScene method seems to not quite fully removing them. 

I’m fairly sure I’m using the composer.removeScene() method correctly. I’m setting the second parameter to ‘false’ so that the lua files are removed and not just recycled.

The call to composer.removeScene() occurs in the ‘scene_remove.lua’ file which is the equivalent of the ‘reloading.lua’ file in your video.

I have attached the project - https://www.dropbox.com/s/061ceo16iolwqa5/Composer%20Tiny%20Game%202.zip

Thanks again in advance,

Mark

I have the same issue as Mark, I remove the scene and go back to the menu, all fine and dandy… but if I then start the game again I will get an error because the things I have placed outside of the listener functions does not get initiated… 

so it does not seem to load the scene/file from scratch again… like it did with storyboard and when you purged things.

There seems to be a bug in removeScene() not unloading the scene. Engineering is aware of it.  I’ll prod them on it too.

Rob

awesome, hope it gets fixed soon :slight_smile:

Thanks for your replies - looking forward to the issue being fixed soon too :slight_smile: