Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Centralize logic for silencing sound effects.

  • Loading branch information...
commit c3b46a5c40a97b3c801a2bb7e802527c23643868 1 parent a001ae2
@jimmycuadra authored
View
4 source/javascripts/application.js.coffee
@@ -80,7 +80,7 @@ class ph.Application
@store.set("score", @store.get("score") + score)
@store.set("chain", chain) if chain > @store.get("chain")
- ph.app.sfx.trigger("play", "match") if ph.app.store.get("playSoundEffects")
+ ph.app.sfx.trigger("play", "match")
_.each marked, (cell) ->
cell.trigger("clear")
@@ -88,7 +88,7 @@ class ph.Application
# for this.
setTimeout(
->
- ph.app.sfx.trigger("play", "fill") if ph.app.store.get("playSoundEffects")
+ ph.app.sfx.trigger("play", "fill")
_.each marked.slice().reverse(), (cell) ->
cell.trigger("refill")
ph.app.trigger("push", chain + 1)
View
2  source/javascripts/collections/sounds.js.coffee
@@ -5,6 +5,8 @@ class ph.Sounds extends Backbone.Collection
@on("play", @play, this)
play: (name) ->
+ return unless ph.app.store.get("playSoundEffects")
+
sounds = @where(name: name)
_.each sounds, (sound) ->
sound.reset() if sound.isPlaying()
View
2  source/javascripts/views/cell_row_view.js.coffee
@@ -25,5 +25,5 @@ class ph.CellRowView extends Backbone.View
newColor = nextColor
nextColor = cell.get("color")
cell.set("color", newColor)
- ph.app.sfx.trigger("play", "push") if ph.app.store.get("playSoundEffects")
+ ph.app.sfx.trigger("play", "push")
ph.app.trigger("push")
Please sign in to comment.
Something went wrong with that request. Please try again.