Permalink
Browse files

Centralize logic for silencing sound effects.

  • Loading branch information...
jimmycuadra committed Nov 22, 2012
1 parent a001ae2 commit c3b46a5c40a97b3c801a2bb7e802527c23643868
@@ -80,15 +80,15 @@ 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")
# Forced delay to keep the sounds from overlapping. Find a better solution
# 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)
@@ -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()
@@ -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")

0 comments on commit c3b46a5

Please sign in to comment.