Does changing scenes removes old scene data?

Hello, my project has actually 2 scenes first one is character selection after confirm it load scene 2 that’s the game. When player die i have made a restart button that reload scene 1. The question is: when i confirm the character again and it reload scene 2 all the entities are duplicated or if existing restored? I ask that because i noticed that some part of scene 2 keep popping up (i can easy solve that but the dubt has entered my mind).

Simply debug it - check what is under app.root entity to ensure there are or there is no entities of other scenes you don’t need.

Yes @max i can do that but since @yaustar told me that destroy and create entities create garbage on memory i was asking for the better way to avoid it. But nevermind i will find out myself thanks.

What do you do at the moment when you go from the character selection scene to the main game? Are you disabling the character selection scene entities?

Yes i do that using tags
like this:

loadLevel: function() {
                    var enEnt= app.root.findByTag('menu');
                    for(var t=0;t<enEnt.length;t++) {
            app.loadSceneHierarchy('396696.json', function(err, entity) {
                if (!err) {
                } else {
                    alert("Level not found.");

Sorry for the confusion i’m making…the restart now reload the first scene, but the raphael windows are duplicated, if i don’t reload it and try to restore the entities of the first scene disabled i get nothing. Some idea?

Are the Raphael windows in the character selection screen or the ‘game’ scene?
When you die, do you reenable the entities with the tag ‘menu’ and disable all the entities from the ‘game’ scene?
And after you select your character on the second time, do you call ‘loadLevel’ or do you enabled the entities from the ‘game’ scene?
Where does your code create the Rapheal windows? What is calling that code/function? Why?

The Raphael windows for character are in buttons.js and CharSelect.js in UI entity of scene 510300(select) and the restartSheet.js in scene 396696(game) is loadLevel for both back and forward. Raphael windows are used for all the windows in game and also gui

In which case you need to look at where your Raphael windows are created in the character select scene and why it is duplicating the creation.

Things that I would be thinking about are:

  • What do you do with the Raphael Windows if you disable all the entities with the ‘menu’ tag. Are they disabled or destroyed?
  • If they are disabled then is there anything in the code that would create new windows instead of enabling the existing windows?

Uhm you are right…i remember the issue with 2 entities with the same name…if i reload the scene i guess the entities are duplicated since the first ones are just disabled and not destroyed. So i think i end up having a new raphael window created and the old one re-enabled at first change…same issue with the models i think. But if i re-enable the old entities they are not displayed…uhm…have to think about that

Found it!! :stuck_out_tongue: my mistake in the routine to enable the menu entities :blush: sorry. Now the comeback to menu works, will work on the go again in game function now. Thanks a lot for your assistance guys. PS: i want make some small tutorial about some problem i have solved that can help others too, is better if i put it on the general section of forum or i make some page on my site?