Hi campers. about coding structure

Hi, I am trying to access the “my-scene” class instance in javascript and call a method.
But I failed so far… its more of design pattern question, but I call

 let cor=  this.game.scene.add('Scene', new MyScene(), true);  setInterval(()=>{

etc…
how do I access that myscene instance? and call a method is it possible?
or the other way around how to make an event that arrives at the main class from my scene?

I find out that it is possible to send events, like so
cor.=> cor.events.addListener('abra',this.br)
so it kind of listening for events in the instance.
Maybe can work I need to test more but thanks anyways

Try:

this.game.scene.add('Scene', MyScene, true);
let cor = this.game.scene.getScene('Scene');

https://photonstorm.github.io/phaser3-docs/Phaser.Scenes.SceneManager.html#getScene

yes it works but in my class 'myscene’ instance there is for example an increment method, how do i access it from the main class?
this is not working.
cor.increment()
=)
anyway thanks

Technically, if you use getScene(…) to get your scene object, you should be able to just call the function on it normally cor.myFunction(...).

Without knowing the extent of what you’re trying to do, for me this is a weird way to use scenes. So one thing you could do is in your MyScene object add a listener to an ‘increment’ event, then outside of it you can go cor.emit('increment');.

Yes I stumbled on the event it is clear the event prototype is working at least, Yes it is maybe a bit odd to use it that way, I am just looking for ways to implement more game data and values in the HTML GUI.
But thanks mate if I type Myscene.prototype. => all methods pop up though so I am not sure how to use it yet, but thanks for your input!