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])

View File

@@ -275,7 +275,16 @@
(actions/do-dialogue entities :ego "Yes! Now, before he gets back!")
(actions/pause-camera entities)
(actions/walk-straight-to entities :ego [173 51] :anim :jump :update-baseline? false :speed 2.0)
(actions/walk-straight-to entities :ego [204 -40] :anim :stand :update-baseline? false :speed 3.0))
(actions/walk-straight-to entities :ego [200 -80] :anim :stand :update-baseline? false :speed 3.0)
(actions/remove-item entities :dream-sword)
(actions/remove-item entities :broom)
(actions/remove-item entities :shovel)
(actions/transition-background entities :inside-castle [79 145] :time 5.0)
(actions/walk-to entities :ego [159 74])
(actions/do-dialogue entities
:ego "Man! What a dream!"
:ego "If I only really could be a knight."
:ego "Then I'd be able to win Georgia McGorgeous' heart."))
(do (actions/walk-to entities :ego [148 76] :face :right)
(actions/do-dialogue entities
:fairy-godfather "What are you doing?" :ego "Erm... Nothing."))))})