totally reworking music transitions.
This commit is contained in:
@@ -464,30 +464,29 @@
|
||||
music
|
||||
(time music)))
|
||||
|
||||
(defn transition-music
|
||||
([entities new-music]
|
||||
(transition-music entities (get-music (get-in @entities [:room :music]) (get-in @entities [:state :time])) new-music))
|
||||
([entities old-music new-music]
|
||||
(let [current-volume (atom 1.0)]
|
||||
(run-action entities
|
||||
(begin [this screen entities]
|
||||
(defn transition-music [entities new-music]
|
||||
(let [current-volume (atom 1.0)]
|
||||
(run-action entities
|
||||
(begin [this screen entities]
|
||||
(assoc-in entities [:tweens :fade-out-music] (utils/tween :fade-out-music screen [:volume :value] 1.0 0.0 2.0)))
|
||||
|
||||
(continue [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]
|
||||
(nil? (get-in entities [:tweens :fade-out-music])))
|
||||
|
||||
(done? [this screen entities]
|
||||
(>= 0.1 @current-volume))
|
||||
(terminate [this screen entities]
|
||||
(music! (utils/get-current-music entities) :stop)
|
||||
(let [entities (-> entities
|
||||
(assoc-in [:music-override :value] new-music)
|
||||
(assoc-in [:volume :value] 1.0))]
|
||||
(music! (utils/get-current-music entities) :set-volume 1.0)
|
||||
(music! (utils/get-current-music entities) :play)
|
||||
entities))
|
||||
|
||||
(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)))))
|
||||
(can-skip? [this screen entities]
|
||||
false))))
|
||||
|
||||
|
||||
(defn transition-background [entities new-background [x y]]
|
||||
@@ -498,9 +497,12 @@
|
||||
(begin [this screen entities]
|
||||
(doseq [[k] (get-in entities [:room :timers])]
|
||||
(remove-timer! screen k))
|
||||
(-> entities
|
||||
(assoc-in [:tweens :fade-out] (utils/tween :fade-out screen [:fade :opacity] 0.0 1.0 0.5))
|
||||
(assoc-in [:cursor :current] :main)))
|
||||
(as-> entities e
|
||||
(assoc-in e [:tweens :fade-out] (utils/tween :fade-out screen [:fade :opacity] 0.0 1.0 0.5))
|
||||
(if music-changed?
|
||||
(assoc-in e [:tweens :fade-out-music] (utils/tween :fade-out-music screen [:volume :value] 1.0 0.0 0.5))
|
||||
e)
|
||||
(assoc-in e [:cursor :current] :main)))
|
||||
|
||||
(continue [this screen entities]
|
||||
(when music-changed?
|
||||
@@ -510,8 +512,7 @@
|
||||
(done? [this screen entities]
|
||||
(>= (get-in entities [:fade :opacity]) 1.0))
|
||||
|
||||
(terminate [this screen entities]
|
||||
(println "done")
|
||||
(terminate [this screen entities]
|
||||
(if-let [next-time (get-in entities [:state :next-time])]
|
||||
(-> entities
|
||||
(assoc-in [:state :time] next-time)
|
||||
@@ -523,11 +524,14 @@
|
||||
(begin [this screen entities]
|
||||
(let [ego (get-in entities [:room :entities :ego])
|
||||
old-music (get-music (get-in entities [:room :music]) (get-in entities [:state :time]))
|
||||
entities (-> entities
|
||||
(assoc-in [:room] (get-in entities [:rooms new-background]))
|
||||
(assoc-in [:room :entities :ego] ego)
|
||||
(assoc-in [:state :last-room] new-background)
|
||||
(assoc-in [:tweens :fade-in] (utils/tween :fade-in screen [:fade :opacity] 1.0 0.0 0.5)))
|
||||
entities (as-> entities e
|
||||
(assoc-in e [:room] (get-in entities [:rooms new-background]))
|
||||
(assoc-in e [:room :entities :ego] ego)
|
||||
(assoc-in e [:state :last-room] new-background)
|
||||
(assoc-in e [:tweens :fade-in] (utils/tween :fade-in screen [:fade :opacity] 1.0 0.0 0.5))
|
||||
(if music-changed?
|
||||
(assoc-in e [:tweens :fade-in-music] (utils/tween :fade-in-music screen [:volume :value] 0.0 1.0 0.5))
|
||||
e))
|
||||
new-music (get-music (get-in entities [:room :music]) (get-in entities [:state :time]))
|
||||
apply-state (get-in entities [:room :apply-state])
|
||||
entities (if apply-state
|
||||
@@ -545,8 +549,6 @@
|
||||
(update-in [:room :entities :ego] #(jump-to screen entities % [x y] true)))))
|
||||
|
||||
(continue [this screen entities]
|
||||
(when music-changed?
|
||||
(music! (get-in entities [:musics new-music]) :set-volume (max (- 1.0 (get-in entities [:fade :opacity])) 0.0)))
|
||||
entities)
|
||||
|
||||
(done? [this screen entities]
|
||||
|
||||
Reference in New Issue
Block a user