Skip to content

Commit

Permalink
Added key to mute bgm
Browse files Browse the repository at this point in the history
  • Loading branch information
satanas committed Mar 9, 2015
1 parent 93a2f22 commit d87d132
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.html
Expand Up @@ -41,7 +41,9 @@
<div id="container">
<div id="game"></div>
<!-- p class="instructions">Infectors is a sokoban-like game where you have to capture viruses in cryogenic capsules.</p -->
<p class="instructions">CONTROLS: Move with the arrow keys, Escape for menu, R to restart, Q to quit</p>
<p class="instructions">CONTROLS</p>
<p class="instructions">Move with the arrow keys, Escape for menu, R to restart, Q to quit, M to mute</p>
<br/>
<p class="instructions">Version 0.8.0 – Created by <a href="http://twitter.com/satanas82">Wil Alvarez</a></p>
</div>
</body>
Expand Down
14 changes: 14 additions & 0 deletions play.js
Expand Up @@ -10,6 +10,7 @@ var playState = {
this.map = null;
this.player = null;
this.sceneDelay = 500;
this.muted = false;
this.bgmPool = new AudioPool(['track1', 'track2', 'track3', 'track4', 'track5', 'track6']);
game.sound.stopAll();
this.bgmPool.randomPlay(true);
Expand Down Expand Up @@ -67,6 +68,9 @@ var playState = {
this.restartKey = game.input.keyboard.addKey(Phaser.Keyboard.R);
this.restartKey.onUp.add(this.restartGame, this);

this.muteKey = game.input.keyboard.addKey(Phaser.Keyboard.M);
this.muteKey.onUp.add(this.muteGame, this);

//groups.walls.debug = true;
this.pausedGame = false;
this.pauseKey = game.input.keyboard.addKey(Phaser.Keyboard.ESC);
Expand Down Expand Up @@ -117,6 +121,16 @@ var playState = {
game.state.start('menu');
},

muteGame: function() {
this.muted = !this.muted;

if (this.muted) {
this.bgmPool.stop();
} else {
this.bgmPool.resume();
}
},

//render: function() {
// game.debug.body(this.player);
// game.debug.bodyInfo(this.player, 10, 20);
Expand Down

0 comments on commit d87d132

Please sign in to comment.