this.scene.start("Setting");
클릭시 화면을 이동시키려면 pointerdown
이벤트를 등록하면 된다.
this.add
.text(400, 300, "Game Start", {
fontSize: "50px",
fontStyle: "bold",
color: "#000000",
})
.setOrigin(0.5)
.setInteractive()
.on("pointerdown", () => {
this.scene.start("Setting");
});
this
는 Phaser.Scene을 가리켜야하기 때문에 arrow function을 사용키보드를 통해서 화면을 이동시키려면 keyboard.once
이벤트를 등록하면 된다.
this.input.keyboard.once("keyup-ESC", () => {
this.scene.start("Home");
});
화면에 재진입시 키보드 설정을 재등록이 되기에 shutdown을 해줘야 한다.
create() {
this.events.on("shutdown", this.shutdown, this);
}
shutdown() {
this.input.keyboard.shutdown();
}