more starting of the fight.

This commit is contained in:
2014-12-11 16:22:16 -08:00
parent ad70fd76b6
commit 1ac686039a
5 changed files with 43 additions and 4 deletions

View File

@@ -394,6 +394,31 @@
(can-skip? [this screen entities]
false)))
(defn transition-music
([entities new-music]
(transition-music entities (get-in @entities [:room :music]) new-music))
([entities old-music new-music]
(let [current-volume (atom 1.0)]
(run-action entities
(begin [this screen entities]
entities)
(continue [this screen entities]
(let [new-volume (swap! current-volume #(- % 0.01))]
(music! (get-in entities [:musics old-music]) :set-volume new-volume))
entities)
(done? [this screen entities]
(>= 0.1 @current-volume))
(terminate [this screen entities]
(music! (get-in entities [:musics old-music]) :stop)
(music! (get-in entities [:musics new-music]) :set-volume 1.0)
(music! (get-in entities [:musics new-music]) :play)
entities)
(can-skip? [this screen entities]
false)))))
(defn transition-background [entities new-background [x y]]
(let [old-music (get-in @entities [:room :music])
new-music (get-in @entities [:rooms new-background :music])