Hi,
I wish to emit 2 events across 2 scenes (but in a specific way).
I’ve got a working version which emits an event to another scene and logs in the console.
However, I would like it to work something like this:
create() {
this.scene.get('GameSc').events.on('event1', function() {
triggered = true;
if(triggered){
this.scene.get('GameSc').events.once('event2', this.handler);
}
});
}
handler() {
console.log('triggered');
triggered=false;
}
It unfortunately doesn’t work - Cannot read property ‘get’ of undefined on the second event.
If i separate the events out into the create function by themselves, they both fire without issue. But i need one to be dependent on the other.
So when i store the 2nd event inside a function (outside of create) or conditional it fails.
Any advice will be hugely appreciated.