transition works.
This commit is contained in:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user