Changing scenes cause 'masterGroup' to be a nil?

Hello! 

So I have the project based on ‘CastleDemo’ sample.

The scene rotation is menu-> game -> menu -> game

Once the game loaded first time everything is perfect. Ater game ends I use cleanup and composer.goToScene(“menu”)

However when I go to game scene again I have a crash from mte: mte.lua:11072 attempt to index upvalue masterGroup (a nil value).

Any ideas what could go wrong or were shall I look into?

Thanks in advance

I came across this problem a few months ago, and asked the MTE boards and people avoided it :slight_smile: It’s a very deep question, and the conclusion is a bit painful. Now i’m gonna assume you have display objects being used in Tiled editor that are called in the program? When I wrote my code I would automatically try to clean out objects when I changed maps or when they are not being used as common practice and the MTE engine since you are using cleanup tries to do the same thing.

When I looked into the MTE engine I believe the cleanup tries to clean everything up but there is also a cleanup part in the map loading function which is doing a double cleanup causing problems? There is also another cleanup part for a different map part in the code…anyways I started to clean everything up manually myself as common practice and commented out the map function cleaning parts in the game engine and I haven’t gotten any problems ever since ( no errors ) . I believe I still use cleanup function from MTE before I change scenes as it does the normal map itself part, I just don’t let it do the objects of it anymore. I came to this conclusion after narrowing it down to any object on the map from Tiled causes this error when only changing scenes.

Good luck!

I came across this problem a few months ago, and asked the MTE boards and people avoided it :slight_smile: It’s a very deep question, and the conclusion is a bit painful. Now i’m gonna assume you have display objects being used in Tiled editor that are called in the program? When I wrote my code I would automatically try to clean out objects when I changed maps or when they are not being used as common practice and the MTE engine since you are using cleanup tries to do the same thing.

When I looked into the MTE engine I believe the cleanup tries to clean everything up but there is also a cleanup part in the map loading function which is doing a double cleanup causing problems? There is also another cleanup part for a different map part in the code…anyways I started to clean everything up manually myself as common practice and commented out the map function cleaning parts in the game engine and I haven’t gotten any problems ever since ( no errors ) . I believe I still use cleanup function from MTE before I change scenes as it does the normal map itself part, I just don’t let it do the objects of it anymore. I came to this conclusion after narrowing it down to any object on the map from Tiled causes this error when only changing scenes.

Good luck!