Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Resetting manually or reloading a whole scene?
Started by Blex Aug 07 2018 12:25 PM

2 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Blex

[GLOBAL: userInfoPane.html]
Blex
  • Corona Geek

  • 1,197 posts
  • Corona SDK

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)



[TOPIC: post.html]
#2

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 2,985 posts
  • Corona SDK

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.



[TOPIC: post.html]
#3

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,968 posts
  • Corona Staff

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




[topic_controls]
[/topic_controls]