offsets fixed

This commit is contained in:
Bryce Covert
2017-05-30 20:44:06 -07:00
parent de78c56d44
commit 6580bbb52b

View File

@@ -13,19 +13,24 @@
:mouse-in? (fn [entities x y]
(let [e (utils/get-entity entities id)]
(if-let [[bx1 by1 bx2 by2] (:box e)]
(zone/within bx1 by1 bx2 by2 x y)
(do (println "checking 1" id)
(zone/within bx1 by1 bx2 by2 x y))
(let [{^float entity-x :x ^float entity-y :y width :width scale-x :scale-x scale-y :scale-y origin-x :origin-x origin-y :origin-y height :height region :object} (-> entities :room :entities id)
width (or width (if (instance? TextureRegion region ) (.getRegionWidth ^TextureRegion region) 0))
height (or height (if (instance? TextureRegion region ) (.getRegionHeight ^TextureRegion region) 0))
entity-x (double (unchecked-add (float entity-x) (unchecked-multiply (float (or origin-x 0))
(float (or scale-x 1)))))
entity-y (double (unchecked-add (float entity-y) (unchecked-multiply (float (or origin-y 0))
(float (or scale-y 1)))))]
entity-x (double (unchecked-add (float entity-x) (unchecked-multiply (float -1.0)
(unchecked-multiply (float (or origin-x 0))
(float (or scale-x 1))))))
entity-y (double (unchecked-add (float entity-y) (unchecked-multiply
(float -1.0)
(unchecked-multiply (float (or origin-y 0))
(float (or scale-y 1))))))]
(zone/within entity-x entity-y
(unchecked-add (float entity-x) (unchecked-multiply (float width) (float (or scale-x 1))))
(unchecked-add (float entity-y) (unchecked-multiply (float height) (float (or scale-y 1)))) x y)))))}
(unchecked-add (float entity-y) (unchecked-multiply (float height) (float (or scale-y 1))))
x y)))))}
(when (or script scripts only-script)
{:get-script (fn [cursor [x y]]
(cond only-script