made a squatting animation
This commit is contained in:
@@ -41,11 +41,14 @@
|
||||
(assoc entity :scale-x (scale-fn [x y]) :scale-y (scale-fn [x y]))
|
||||
entity)))
|
||||
|
||||
(defn find-animation [entity anim]
|
||||
(if (keyword? anim)
|
||||
(or (get-in entity [(:facing entity) anim])
|
||||
(anim entity))
|
||||
anim))
|
||||
|
||||
(defn start-animation [screen entity anim]
|
||||
(let [new-anim (if (keyword? anim)
|
||||
(or (get-in entity [(:facing entity) anim])
|
||||
(anim entity))
|
||||
anim)]
|
||||
(let [new-anim (find-animation entity anim)]
|
||||
(if (and anim (not= new-anim (:anim entity)))
|
||||
(assoc entity
|
||||
:anim new-anim
|
||||
@@ -107,6 +110,23 @@
|
||||
(can-skip? [this screen entities]
|
||||
false))))
|
||||
|
||||
(defn play-animation [entities target-id anim]
|
||||
(run-action entities
|
||||
(begin [this screen entities]
|
||||
(update-in entities [:room :entities target-id] #(start-animation screen % anim) ))
|
||||
|
||||
(continue [this screen entities] entities)
|
||||
|
||||
(done? [this screen entities]
|
||||
(animation! (find-animation (get-in entities [:room :entities target-id ]) anim)
|
||||
:is-animation-finished
|
||||
(- (:total-time screen) (get-in entities [:room :entities target-id :anim-start]))))
|
||||
|
||||
(terminate [this screen entities]
|
||||
(stop screen entities target-id))
|
||||
(can-skip? [this screen entities]
|
||||
false)))
|
||||
|
||||
(defn walk-to [entities target-id [final-x final-y] & [can-skip?]]
|
||||
(let [{start-x :x start-y :y} (get-in @entities [:room :entities target-id])
|
||||
final-x (int final-x)
|
||||
|
||||
Reference in New Issue
Block a user