fixing bugs.
This commit is contained in:
@@ -187,14 +187,15 @@
|
||||
|
||||
(defn start-animation
|
||||
([entity anim]
|
||||
(start-animation {:total-time 0} entity anim))
|
||||
(start-animation {:total-time 0} entity anim))
|
||||
([screen entity anim]
|
||||
(let [new-anim (find-animation entity anim)]
|
||||
(if (and anim (not= new-anim (:anim entity)))
|
||||
(assoc entity
|
||||
:anim new-anim
|
||||
:anim-start (:total-time screen))
|
||||
entity))))
|
||||
(let [new-anim (find-animation entity anim)]
|
||||
(if (and anim (not= new-anim (:anim entity)))
|
||||
(assoc entity
|
||||
:force-rerender true
|
||||
:anim new-anim
|
||||
:anim-start (:total-time screen))
|
||||
entity))))
|
||||
|
||||
(defn stop [screen entities target-id & {:keys [face]}]
|
||||
(update-in entities [:room :entities target-id] (comp #(start-animation screen % (or (:stand-override %) :stand) ) (if face #(assoc % :facing face) identity))))
|
||||
|
||||
@@ -855,10 +855,12 @@
|
||||
(if anim-loop?
|
||||
(get-looped-animation-point anim last-animated-time)
|
||||
last-animated-time))]
|
||||
(if (= current-frame-index (:current-frame-index entity) (:previous-frame-index entity))
|
||||
(if (and (= current-frame-index (:current-frame-index entity) (:previous-frame-index entity))
|
||||
(not (:force-rerender entity)))
|
||||
entity
|
||||
(merge (assoc entity
|
||||
:object (.getKeyFrame ^Animation anim (- total-time anim-start) anim-loop?)
|
||||
:force-rerender nil
|
||||
:current-frame-index current-frame-index
|
||||
:previous-frame-index previous-frame-index
|
||||
:origin-x (or (-> entity :anim-origins (get anim) (nth 0))
|
||||
@@ -1819,6 +1821,15 @@
|
||||
:else
|
||||
nil))
|
||||
|
||||
|
||||
(defn update-hud-active [screen entities options]
|
||||
(let [[x y] (utils/unproject screen options)
|
||||
hovered-inventory? (utils/intersects? (:inventory entities) [x y])
|
||||
hovered-close? (utils/intersects? (:close entities) [x y])
|
||||
hovered-save? (utils/intersects? (:save entities) [x y])]
|
||||
|
||||
(screen! scene :hud-active? { :hud-active? (or hovered-close? hovered-inventory? hovered-save?)})))
|
||||
|
||||
(defscreen hud
|
||||
:on-show
|
||||
(fn [screen entities options]
|
||||
@@ -1959,16 +1970,17 @@
|
||||
|
||||
:on-touch-down
|
||||
(fn [screen entities options]
|
||||
(let [[x y] (utils/unproject screen options)
|
||||
hovered-inventory? (utils/intersects? (:inventory entities) [x y])
|
||||
hovered-close? (utils/intersects? (:close entities) [x y])
|
||||
hovered-save? (utils/intersects? (:save entities) [x y])]
|
||||
(update-hud-active screen entities options))
|
||||
|
||||
:on-touch-dragged
|
||||
(fn [screen entities options]
|
||||
(update-hud-active screen entities options))
|
||||
|
||||
(screen! scene :hud-active? { :hud-active? (or hovered-close? hovered-inventory? hovered-save?)})))
|
||||
|
||||
:on-mouse-moved
|
||||
|
||||
(fn [screen entities options]
|
||||
(update-hud-active screen entities options)
|
||||
(let [[x y] (utils/unproject screen options)
|
||||
hovered-inventory? (utils/intersects? (:inventory entities) [x y])
|
||||
hovered-close? (utils/intersects? (:close entities) [x y])
|
||||
@@ -1994,8 +2006,7 @@
|
||||
entities)
|
||||
entities (grow-hud screen entities :close false)
|
||||
entities (grow-hud screen entities :save false)]
|
||||
entities
|
||||
))))
|
||||
entities))))
|
||||
|
||||
|
||||
:on-touch-up
|
||||
|
||||
@@ -524,7 +524,8 @@
|
||||
|
||||
(get-in entities [:state :hud-active?])
|
||||
(-> entities
|
||||
(assoc-in [:cursor :override] nil))
|
||||
(assoc-in [:cursor :override] nil)
|
||||
(assoc-in [:label :text] ""))
|
||||
|
||||
(and mouse-override (:only-script mouse-override))
|
||||
(-> entities
|
||||
|
||||
Reference in New Issue
Block a user