transition works.

This commit is contained in:
2015-04-17 18:23:49 -07:00
parent e6dc4a9382
commit b262ac7072
2 changed files with 17 additions and 7 deletions

View File

@@ -569,19 +569,20 @@
false))))
(defn transition-background [entities new-background [x y] & {:keys [transition-music? between]}]
(defn transition-background [entities new-background [x y] & {:keys [transition-music? between time]}]
(let [transition-music? (if (nil? transition-music?) true transition-music?)
old-music (get-music (get-in @entities [:room :music]) (get-in @entities [:state :time]))
new-music (get-music (get-in @entities [:rooms new-background :music]) (get-in @entities [:state :time]))
music-changed? (and transition-music? (not= old-music new-music))]
music-changed? (and transition-music? (not= old-music new-music))
time (/ (float (or time 1.0)) 2.0)]
(run-action entities
(begin [this screen entities]
(doseq [[k] (get-in entities [:room :timers])]
(remove-timer! screen k))
(as-> entities e
(assoc-in e [:tweens :fade-out] (tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 0.5))
(assoc-in e [:tweens :fade-out] (tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 time))
(if music-changed?
(assoc-in e [:tweens :fade-out-music] (tween/tween :fade-out-music screen [:volume :value] 1.0 0.0 0.5))
(assoc-in e [:tweens :fade-out-music] (tween/tween :fade-out-music screen [:volume :value] 1.0 0.0 time))
e)
(assoc-in e [:cursor :current] :main)))
@@ -608,13 +609,13 @@
(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] (tween/tween :fade-in screen [:fade :opacity] 1.0 0.0 0.5))
(assoc-in e [:tweens :fade-in] (tween/tween :fade-in screen [:fade :opacity] 1.0 0.0 time))
(update-in e [:tweens] dissoc :cam-zoom :cam-x :cam-y)
(assoc-in e [:cam :x] 160)
(assoc-in e [:cam :y] 120)
(assoc-in e [:cam :zoom] 0.95)
(if music-changed?
(assoc-in e [:tweens :fade-in-music] (tween/tween :fade-in-music screen [:volume :value] 0.0 1.0 0.5))
(assoc-in e [:tweens :fade-in-music] (tween/tween :fade-in-music screen [:volume :value] 0.0 1.0 time))
e))
new-music (get-music (get-in entities [:room :music]) (get-in entities [:state :time]))
apply-state (get-in entities [:room :apply-state])