From 99de5ea97286699cf6170e70b962644dbfef243f Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Thu, 9 Feb 2017 09:29:00 -0800 Subject: [PATCH] step in the direction of having a rotating pack. --- desktop/src-common/advent/screens/scene.clj | 43 +++++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 8e21b591..fd5b17e7 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -1539,17 +1539,18 @@ (let [fade-tween (if (= :hide hide-or-show) (tween/tween :appear-item screen [:selected-item :opacity] 1.0 0.0 0.5 :ease tween/ease-linear) (tween/tween :appear-item screen [:selected-item :opacity] 0.0 1.0 0.5 :ease tween/ease-linear)) + move-tween (condp = in-or-out :far-out - (tween/tween :appear-item-y screen [:selected-item :y] (* utils/ui-scale 35) (* utils/ui-scale 40) 0.5 :ease tween/ease-linear) + (tween/tween :appear-item-y screen [:selected-item :x] (* utils/ui-scale 45) (* utils/ui-scale 50) 0.5 :ease tween/ease-linear) :out - (tween/tween :appear-item-y screen [:selected-item :y] (* utils/ui-scale 30) (* utils/ui-scale 35) 0.5 :ease tween/ease-linear) + (tween/tween :appear-item-y screen [:selected-item :x] (* utils/ui-scale 40) (* utils/ui-scale 45) 0.5 :ease tween/ease-linear) :in - (tween/tween :appear-item-y screen [:selected-item :y] (* utils/ui-scale 35) (* utils/ui-scale 30) 0.5 :ease tween/ease-linear) + (tween/tween :appear-item-y screen [:selected-item :x] (* utils/ui-scale 45) (* utils/ui-scale 40) 0.5 :ease tween/ease-linear) :none - (tween/tween :appear-item-y screen [:selected-item :y] (* utils/ui-scale 35) (* utils/ui-scale 35) 0.5 :ease tween/ease-linear))] + (tween/tween :appear-item-y screen [:selected-item :x] (* utils/ui-scale 45) (* utils/ui-scale 45) 0.5 :ease tween/ease-linear))] (-> entities (assoc :selected-item (assoc (texture (aget (get-in entities [:all-items]) 0 (.indexOf utils/+all-cursors+ (:cursor item)))) @@ -1557,8 +1558,7 @@ :origin-y 0 :scale-x utils/ui-scale :scale-y utils/ui-scale - :x (- 320 (* utils/ui-scale 12)) - :y (* utils/ui-scale (condp = in-or-out + :x (* utils/ui-scale (condp = in-or-out :in 35 :out @@ -1566,9 +1566,11 @@ :none 35 :far-out - 35)) :baseline 9000 :opacity (if (= :hide hide-or-show) 1.0 0.0) + 35)) + :y (* utils/ui-scale 0) :baseline 9000 :opacity (if (= :hide hide-or-show) 1.0 0.0) :item item)) (assoc-in [:tweens :appear-item] fade-tween) + (assoc-in [:tweens :appear-item-y] move-tween)))) (transition-done? [this screen entities] (not (get-in entities [:tweens :appear-item]))))) @@ -1578,7 +1580,14 @@ (accept-state entities state state-data [(reify ITransition (start-transition [this screen entities] - (update-in entities [:inventory] #(actions/start-animation screen % :open))) + (let [rotate-tween (tween/tween :rotate-pack screen [:inventory :angle] 0.0 -90.0 0.25 :ease tween/ease-linear) + y-tween (tween/tween :y-pack screen [:inventory :y] (* utils/ui-scale 21) (* utils/ui-scale 5) 0.25 :ease tween/ease-linear) + x-tween (tween/tween :x-pack screen [:inventory :x] (* utils/ui-scale 24) (* utils/ui-scale 15) 0.25 :ease tween/ease-linear)] + (-> entities + (assoc-in [:tweens :rotate-pack] rotate-tween) + (assoc-in [:tweens :y-pack] y-tween) + (assoc-in [:tweens :x-pack] x-tween) + (update-in [:inventory] #(actions/start-animation screen % :open))))) (transition-done? [this screen entities] (animation! (get-in entities [:inventory :anim]) :is-animation-finished @@ -1803,23 +1812,23 @@ :width 16 :height 16 :baseline 9000 :opacity 0.8) - :inventory (assoc (utils/get-texture "inventory.png") :x (- 320 (* 21 utils/ui-scale)) :y (* 27 utils/ui-scale ) :baseline 9000 + :inventory (assoc (utils/get-texture "inventory.png") :x (* 21 utils/ui-scale ) :y (* 27 utils/ui-scale ) :baseline 9000 :intersect-width 42 :intersect-height 48 :width 42 :height 56 :origin-x 21 :origin-y 27 :scale-x utils/ui-scale :scale-y utils/ui-scale - :open (doto (utils/make-anim-seq "open-inventory" [42 56] 0.055 (flatten [(range 6) 6 7 8 7 ])) - (animation! :set-play-mode (play-mode :normal))) - :anim (utils/make-anim "inventory.png" [42 56] 0.1 [0]) + :open (utils/flip (doto (utils/make-anim-seq "open-inventory" [42 56] 0.055 (flatten [(range 6) 6 7 8 7 ])) + (animation! :set-play-mode (play-mode :normal)))) + :anim (utils/flip (utils/make-anim "inventory.png" [42 56] 0.1 [0])) :anim-loop? false - :default (utils/make-anim "inventory.png" [42 56] 0.1 [0]) - :opened (utils/make-anim-seq "open-inventory" [42 56] 0.1 [7]) - :closing (doto (utils/make-anim-seq "open-inventory" [42 56] 0.055 [7 7 7 7 7 7 7 9 10 11 12 0]) - (animation! :set-play-mode (play-mode :normal))) + :default (utils/flip (utils/make-anim "inventory.png" [42 56] 0.1 [0])) + :opened (utils/flip (utils/make-anim-seq "open-inventory" [42 56] 0.1 [7])) + :closing (utils/flip (doto (utils/make-anim-seq "open-inventory" [42 56] 0.055 [7 7 7 7 7 7 7 9 10 11 12 0]) + (animation! :set-play-mode (play-mode :normal)))) :anim-start 0 :opacity 0.8) :all-items (texture! (texture (pixmap "cursor.png")) :split 18 16) - :fps (->> (assoc (label "" (color :white) ) :y 30 :x 5 :baseline 0 :opacity 0.1) + :fps (->> (assoc (label "" (color :white) ) :y 10 :x 280 :baseline 0 :opacity 0.1) (utils/add-actor-to-stage screen))})) :on-render