Resetting manually or reloading a whole scene?

Here’s a quick question, should I stick to manual reloading, or should I just reload via .gotoScene()?

My code is long due to manual reloading and I would like to compact it, but at the same time, I have heard that (performance-wise) it is better to reload manually. (reset positions instead of deleting objects)

I think it all depends on whether you can make it a smooth user experience. For example, if you can give them something to look at while the reload takes place it can lessen the impact and even improve the experience.

Having said that, if you have physics objects you might want to recreate them from scratch - though I expect you’ve solved that problem, if it’s there.

I don’t reload scenes, personally. I have the ‘scene’ in a module (ie: wrapped up within a custom group) and I simply destroy that group and recreate a new instance of it within the same scene. This negates the need to leave the scene at all. The extra work required to provide a smooth transition off screen etc is minimal, tbh.

There are tons of types of games, so without knowing more about the game you’re making, it’s really hard to suggest if you should use a cutscene/level over/next level screen so you can do a removeScene/gotoScene or reload in the current scene.  There are two types of “efficiency” to consider:

  1. Programmer efficiency. There is no doubt, anywhere beyond a fairly simple game, creating a nextlevel.lua and a composer.gotoScene() that lets you remove the game scene to go back to it is the most efficient way for a programmer to go. It’s just a few lines of code. But depending on the game, a cutscene can really add to the game.

  2. Performant efficiency. The idea behind the way Corona caches scenes is to avoid image and audio load times. For many games, loading isn’t a big time-consuming thing so the caching benefit isn’t that great. As long as you have enough memory to hold the textures and the loading doesn’t slow down the transition to the game to an unacceptable level, you shouldn’t care if the scene is cached or not. Today’s modern devices are pretty fast and loading the images is pretty quick. But if your game needs to minimize loading times, then that should push you away from the idea of destroying the scene and re-creating it and push you towards manually repositioning everything.

Rob

I think it all depends on whether you can make it a smooth user experience. For example, if you can give them something to look at while the reload takes place it can lessen the impact and even improve the experience.

Having said that, if you have physics objects you might want to recreate them from scratch - though I expect you’ve solved that problem, if it’s there.

I don’t reload scenes, personally. I have the ‘scene’ in a module (ie: wrapped up within a custom group) and I simply destroy that group and recreate a new instance of it within the same scene. This negates the need to leave the scene at all. The extra work required to provide a smooth transition off screen etc is minimal, tbh.

There are tons of types of games, so without knowing more about the game you’re making, it’s really hard to suggest if you should use a cutscene/level over/next level screen so you can do a removeScene/gotoScene or reload in the current scene.  There are two types of “efficiency” to consider:

  1. Programmer efficiency. There is no doubt, anywhere beyond a fairly simple game, creating a nextlevel.lua and a composer.gotoScene() that lets you remove the game scene to go back to it is the most efficient way for a programmer to go. It’s just a few lines of code. But depending on the game, a cutscene can really add to the game.

  2. Performant efficiency. The idea behind the way Corona caches scenes is to avoid image and audio load times. For many games, loading isn’t a big time-consuming thing so the caching benefit isn’t that great. As long as you have enough memory to hold the textures and the loading doesn’t slow down the transition to the game to an unacceptable level, you shouldn’t care if the scene is cached or not. Today’s modern devices are pretty fast and loading the images is pretty quick. But if your game needs to minimize loading times, then that should push you away from the idea of destroying the scene and re-creating it and push you towards manually repositioning everything.

Rob