I am currently developing an app using Phaser 3 and Angular 6. I am trying to figure out how to implement Dependency Injection in a typescript class (which is a Phaser Scene) in order to call a service (GameService). Any suggestions on how to achieve this?
export class PlayerConfigScene extends Phaser.Scene {
constructor(private gameService: GameService) {
super({
key: "PlayerConfigScene"
});
}
init() {
this.gameService.setEnableForms(true);
}
}
Here is the code for the GameService
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class GameService {
private enableForms : BehaviorSubject<boolean> = new BehaviorSubject<boolean> (false);
constructor() { }
public setEnableForms(flag : boolean) {
this.enableForms.next(flag);
}
public getEnableForms() : BehaviorSubject<boolean> {
return this.enableForms;
}
}