What is the best practice for level management?

Hi there,

I am new to phaser and wanted to ask something fundamental. What is the best way to switch from one level to the next?

I currently, use the same scene object and call restart once the level changes. As the level index is incremented, the create() function creates a new level based on my configuration.

Is this a proper way or should I create a new scene for each level or maybe there is a better way…

I’d be grateful for your guidance.

Thanks,

Doug

I don’t know that I can confirm that your approach is a best practice, but I can confirm that I’ve done things your way and its worked well for me. I currently pass whatever level data I need to into the restart call and use that in my Scene’s create method to construct the level.

1 Like

How do you pass all the data from 1 scene to another, then activate it in the 2nd scene?

I pass the data my scene needs to run via the restart method: https://photonstorm.github.io/phaser3-docs/Phaser.Scenes.ScenePlugin.html#restart__anchor

1 Like

Hi @snowbillr,

Many thanks for your time and for your answer, I do appreciate it.

I create sprites from graphics ( by graphics.generateTexture() ) however, the sprites seem to lose their sharpness after restart.

I feel there might be a better way out there but I will go with this method for now.

Cheers,

Doug

The way you describe seems perfectly fine and convenient. One can say it can be the fundamental way to achieve level management.

I don’t see connection between your sprite sharpness issue and level management via scene restart. Can you elaborate a bit and probably in another post if it is not related to this topic please?

1 Like