From 8c23ded9df81f3b09896222bec0027542843f9bb Mon Sep 17 00:00:00 2001 From: JJongBin Date: Wed, 14 Dec 2022 17:12:39 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[feat]=20#185=20=EA=B2=8C=EC=9E=84=20scene?= =?UTF-8?q?=20=EC=9D=B4=EB=8F=99=EC=8B=9C=20=EC=97=B4=EB=A0=A4=EC=9E=88?= =?UTF-8?q?=EB=8A=94=20=EC=B0=BD=20=EB=8B=AB=EC=95=84=EC=A3=BC=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/component/Game/Scene/town.ts | 2 ++ frontend/src/component/MiniGame/index.tsx | 6 ++++++ frontend/src/component/Sidebar/index.tsx | 11 +++++++++++ frontend/src/component/SleepyBoard/index.tsx | 12 ++++++++++++ 4 files changed, 31 insertions(+) diff --git a/frontend/src/component/Game/Scene/town.ts b/frontend/src/component/Game/Scene/town.ts index 22e1be2..c774a61 100644 --- a/frontend/src/component/Game/Scene/town.ts +++ b/frontend/src/component/Game/Scene/town.ts @@ -137,6 +137,8 @@ export default class Town extends Phaser.Scene { changeScene = (gameName: string) => { console.log(gameName); + emitter.emit('closeContent'); + this.scene.pause(); this.scene.start(gameName, { socket: this.socket, diff --git a/frontend/src/component/MiniGame/index.tsx b/frontend/src/component/MiniGame/index.tsx index 645f957..23d5d60 100644 --- a/frontend/src/component/MiniGame/index.tsx +++ b/frontend/src/component/MiniGame/index.tsx @@ -31,7 +31,13 @@ const MiniGame = () => { setSelectGame(gameName); }); + emitter.on('closeContent', () => { + setIsShowModal(false); + initGame(); + }); + return () => { + emitter.removeListener('closeContent'); emitter.removeListener('game'); }; }, []); diff --git a/frontend/src/component/Sidebar/index.tsx b/frontend/src/component/Sidebar/index.tsx index 97f9a37..8d76dfc 100644 --- a/frontend/src/component/Sidebar/index.tsx +++ b/frontend/src/component/Sidebar/index.tsx @@ -16,6 +16,7 @@ import Setting from './Setting'; import Chat from './Chat'; import { useRecoilState } from 'recoil'; import { sidebarState } from '../../store/atom/sidebar'; +import { emitter } from '../Game/util'; type componentType = { [key: string]: EmotionJSX.Element; @@ -49,6 +50,16 @@ const Sidebar = () => { }); }; + useEffect(() => { + emitter.on('closeContent', () => { + setOpen(false); + }); + + return () => { + emitter.removeListener('closeContent'); + }; + }, []); + return (