Commit 86d9732c authored by 18신대성's avatar 18신대성

사운드 잘 나오게 수정

parent 14d6b942
...@@ -23,18 +23,19 @@ Audio.loadSound = function(scene) ...@@ -23,18 +23,19 @@ Audio.loadSound = function(scene)
scene.load.audio('Phase3', 'assets/sound/Phase3.ogg'); scene.load.audio('Phase3', 'assets/sound/Phase3.ogg');
// 승패 BGM // 승패 BGM
scene.load.audio('defeat', 'assets/sound/victory.ogg'); scene.load.audio('victory', 'assets/sound/victory.ogg');
scene.load.audio('victory', 'assets/sound/defeat.ogg'); scene.load.audio('defeat', 'assets/sound/defeat.ogg');
} }
Audio.playSound = function(scene, title) // 한 번만 재생할 때 사용 Audio.playSound = function(scene, title) // 한 번만 재생할 때 사용
{ {
bgm = scene.sound.add(title); // 추후 수정 예정 let sound = scene.sound.add(title);
bgm.play(); sound.play();
} }
Audio.loopSound = function(scene, title) // 반복재생할 때 사용 Audio.loopSound = function(scene, title) // 반복재생할 때 사용
{ {
if (bgm != null) this.killSound(scene, title);
bgm = scene.sound.add(title); bgm = scene.sound.add(title);
bgm.setLoop(true); bgm.setLoop(true);
bgm.play(); bgm.play();
......
...@@ -354,6 +354,7 @@ socket.on('defeat', function(msg) // object player ...@@ -354,6 +354,7 @@ socket.on('defeat', function(msg) // object player
} }
if(msg.id == RoomData.myself.id) if(msg.id == RoomData.myself.id)
{ {
Audio.loopSound(ScenesData.gameScene, 'defeat');
RoomData.myself = RoomData.players[msg.index]; RoomData.myself = RoomData.players[msg.index];
setTimeout(() => { setTimeout(() => {
gameEndMenu(false); gameEndMenu(false);
...@@ -371,10 +372,10 @@ socket.on('gameEnd', function(msg) // number winnerId ...@@ -371,10 +372,10 @@ socket.on('gameEnd', function(msg) // number winnerId
if(WordSpace.CurrentPhase == 3) if(WordSpace.CurrentPhase == 3)
Audio.killSound(ScenesData.gameScene, 'Phase3'); Audio.killSound(ScenesData.gameScene, 'Phase3');
Audio.playSound(ScenesData.gameScene, 'victory');
console.log(winner.nickname + ' Win!!!!!!'); console.log(winner.nickname + ' Win!!!!!!');
if(msg == RoomData.myself.id) if(msg == RoomData.myself.id)
{ {
Audio.loopSound(ScenesData.gameScene, 'victory');
RoomData.myself.rank = 1; RoomData.myself.rank = 1;
setTimeout(() => { setTimeout(() => {
gameEndMenu(true); gameEndMenu(true);
......
...@@ -387,7 +387,7 @@ Input.inputField = ...@@ -387,7 +387,7 @@ Input.inputField =
Input.pushInput = function(inputKey) Input.pushInput = function(inputKey)
{ {
if ((ScenesData.currentScene != 'gameScene' || RoomData.myself.isAlive) && this.justPressed != inputKey) if (!WordSpace.isGameOver && RoomData.myself.isAlive && this.justPressed != inputKey)
{ {
this.justPressed = inputKey; this.justPressed = inputKey;
let output; let output;
......
...@@ -600,13 +600,6 @@ var gameScene = new Phaser.Class( ...@@ -600,13 +600,6 @@ var gameScene = new Phaser.Class(
BackGround.drawCharacter(this); BackGround.drawCharacter(this);
Audio.playSound(this, 'startGame'); Audio.playSound(this, 'startGame');
if(WordSpace.CurrentPhase == 1)
Audio.loopSound(this, 'Phase1');
else if(WordSpace.CurrentPhase == 2)
Audio.loopSound(this, 'Phase2');
else
Audio.loopSound(this, 'Phase3');
WordSpace.attackPaperGroup = this.physics.add.group(); WordSpace.attackPaperGroup = this.physics.add.group();
WordSpace.wordPhysicsGroup = this.physics.add.group(); WordSpace.wordPhysicsGroup = this.physics.add.group();
......
...@@ -224,8 +224,6 @@ function gameOver() ...@@ -224,8 +224,6 @@ function gameOver()
Audio.killSound(ScenesData.gameScene, 'Phase2'); Audio.killSound(ScenesData.gameScene, 'Phase2');
if(WordSpace.CurrentPhase == 3) if(WordSpace.CurrentPhase == 3)
Audio.killSound(ScenesData.gameScene, 'Phase3'); Audio.killSound(ScenesData.gameScene, 'Phase3');
Audio.playSound(ScenesData.gameScene, 'defeat');
socket.emit('defeated'); socket.emit('defeated');
console.log('defeat'); console.log('defeat');
...@@ -495,11 +493,11 @@ WordSpace.changePhase = function(newPhase) ...@@ -495,11 +493,11 @@ WordSpace.changePhase = function(newPhase)
WordSpace.CurrentPhase = newPhase; WordSpace.CurrentPhase = newPhase;
if(WordSpace.CurrentPhase == 1) if(WordSpace.CurrentPhase == 1)
Audio.killSound('gameScene', 'Phase1'); Audio.loopSound(ScenesData.currentScene, 'Phase1');
else if(WordSpace.CurrentPhase == 2) else if(WordSpace.CurrentPhase == 2)
Audio.killSound('gameScene', 'Phase2'); Audio.loopSound(ScenesData.currentScene, 'Phase2');
else else
Audio.killSound('gameScene', 'Phase3'); Audio.loopSound(ScenesData.currentScene, 'Phase3');
//WordSpace.pauseCycle(true); //WordSpace.pauseCycle(true);
// 여기서 종이 드르륵 열면됨 // 여기서 종이 드르륵 열면됨
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment