From 51534de63edcbbf06a2364fb2b1268ee135da75d Mon Sep 17 00:00:00 2001 From: Licson Lee Date: Sun, 11 Jan 2015 20:06:32 +0800 Subject: [PATCH] Fixed glitches after pressed Escape key to restart game --- bkcore/Audio.js | 4 ++-- bkcore/hexgl/HexGL.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bkcore/Audio.js b/bkcore/Audio.js index 29b2052..95f0ac2 100644 --- a/bkcore/Audio.js +++ b/bkcore/Audio.js @@ -101,8 +101,8 @@ bkcore.Audio.stop = function(id){ if(ctx){ if(bkcore.Audio.sounds[id].bufferNode !== null){ - bkcore.Audio.sounds[id].bufferNode.disconnect(); - bkcore.Audio.sounds[id].bufferNode = null; + var bufferNode = bkcore.Audio.sounds[id].bufferNode; + bufferNode.stop ? bufferNode.stop(ctx.currentTime) : bufferNode.noteOff(ctx.currentTime); } } else { diff --git a/bkcore/hexgl/HexGL.js b/bkcore/hexgl/HexGL.js index cd627e7..4da8e46 100644 --- a/bkcore/hexgl/HexGL.js +++ b/bkcore/hexgl/HexGL.js @@ -113,9 +113,11 @@ bkcore.hexgl.HexGL.prototype.reset = function() this.manager.get('game').objects.lowFPS = 0; this.gameplay.start(); + bkcore.Audio.stop('bg'); + bkcore.Audio.stop('wind'); + bkcore.Audio.volume('wind', 0.35); bkcore.Audio.play('bg'); bkcore.Audio.play('wind'); - bkcore.Audio.volume('wind', 0.35); } bkcore.hexgl.HexGL.prototype.restart = function()