Persisted nodes and canvas

Hello there.

It’s useful to have an option to pass visual elements between scenes (e.g. loading screen). Examples:

  • Loading screen should have nice and shiny disappear animation revealing game content
  • Loaded scene may need to perform some final preparations that could be asynchronous (e.g. fetch avatars)
  • etc.

There is cc.game.addPersistRootNode that seems suitable. At first glance. But then there’s a problem: loading screen needs canvas to adapt to different screen sizes and only root node could be persisted (i.e. canvas in that case) but main scene also has canvas to adapt it’s content to the screen and therefore I get an error about multiple active canvases.

How that should be handled?

My ideas are:

  1. Adapt loading screen by custom code instead of canvas
  2. Have canvas disabled by default on main scene and reattach loading screen content from one canvas to another in loadScene-s callback and then destroy previous one and activate new one (though I didn’t test that. Maybe error message is misleading and you cannot have multiple canvas-es no matter what state they are in). But that would be cumbersome to always maintain that inactive state for main scene canvas when editin.