This is another newbie question, but how do you create a persistent UI elements that will remain on your screen even if different scenes load ? Example would be a settings / sound icons, or a menu.
Hello @SlavomirDurej,
With phaser-3 now you can start multiple scenes.
here is an example about this which is on https://labs.phaser.io/index.html
Thank you, still would be nice if there was just a bit more info about this?
From lookling at the source code I I guessed the way to make it run is by calling this in the constructor?
Phaser.Scene.call(this, { key: ābackgroundā, active: true }); Whereas ākeyā referes to the scenes classes array? But those are class names, the ākeyā variables are defined in constructor normaly, but then sometimes you just call superconstructor e.g. super({key: āGameSceneā}); right?
So when you want to use multiple scenes you use Phaser.Scene.call instead?
And then how do you communicate with those other scenes? What about their position on the z / depth axis ?
Where can I find any documentation / guides about this and similar concepts?
Hello again @SlavomirDurej,
For documentation, you can check: https://photonstorm.github.io/phaser3-docs/
And please see all examples on https://labs.phaser.io/index.html?dir=scenes/&q=
as for multiple scenes when you want, you can use this.scene.launch
see this example.
for passing data from another scene see this example which is also on labs
I believe is the best way check online for your questions.
After all if you really canāt find anything about your problem(which quite unlikely) then please do let us know about your problem and show us your code
I believe there are really tons of questions about UIScene
, similar to your question.
And for me, Iām always looking the source code of phaser before i wrote something here
Update:
Oh bdw just saw this 2 example too:
https://labs.phaser.io/view.html?src=src/scenes/ui%20scene%20es6.js
https://labs.phaser.io/view.html?src=src/scenes/ui%20scene.js -> this one specially called āui scene.jsā on examples
Thank you so much for your help!
Itās not that I didnāt try to look for it, itās just that itās really difficult to look for a specific answers , when you donāt know where to look! Those API docs, are really only helpful, if you already know the general area or a specific area or classes you need to look up. For example this issue would be hidden somewhere in the constructor of the class extending Phaser.Scene by calling superconstructor with super({key: āMenuā, active:true}); (Iām using typescript).
And so it happens this information is burried under: Namespaces > Phaser.Scenes.Settings
(not inside https://photonstorm.github.io/phaser3-docs/Phaser.Scene.html or Scene manager,) etcā¦
which isnāt exactly intuitive?
and even there it says:
active
boolean false Does the Scene start as active or not? An active Scene updates each step.
which still doesnāt mention that it allows these two scenes be visible or coexisting in paralel at the same timeā¦ So for anybody thatās working with Phaser only 2-3 days, this is pretty well hidden Iād say.
Another problem is I know some other game libraries / platforms that have quite a different approach, which makes it a bit harder to use Phaser (such as Unity, OpenFL or Starling).
I see your problem @SlavomirDurej, and really i was also sooo confused when i start working with phaser-3 at first place. But as much as you have write and search for these kinda stuff you learn more as you can imagine.
For this i actually never checked if itās actually starting or not and also about updates idk but we can always ask help from @rich or @samme i believe they and many others can help!
As far as i understand, scenes are creating by SceneManager
but doesnāt start therefor doesnāt have an update on the time.
In the scene config active
determines whether the scene will be started by the SceneManager after the scene is added by the manager. And once the scene is started its sys.settings.active flag is true. Specifically, the active
flag is true for the scene states START and RUNNING and false for the others.
But read #119 and #121 for a guide to the scenes, thatās a better place to start.
Thank you so much @samme this was mega useful! those dev logs should be featured much more prominently in the help section, or better yet, such articles could be compiled to a separate wiki page, and have their own sectionā¦ itās really useful and interesting information.