Remove origin-x/origin-y and add scale-x/scale-y to shape

This commit is contained in:
oakes
2014-05-23 03:20:00 -04:00
parent 1c878bf078
commit 02fb380c58

View File

@@ -86,29 +86,24 @@
(.render renderer object attributes))) (.render renderer object attributes)))
(defrecord ShapeEntity [object] Entity (defrecord ShapeEntity [object] Entity
(draw-entity! [{:keys [^ShapeRenderer object type draw! x y width height (draw-entity! [{:keys [^ShapeRenderer object type draw!
angle origin-x origin-y]} x y scale-x scale-y angle]}
{:keys [^Camera camera]} {:keys [^Camera camera]}
batch] batch]
(when (or x y)
(let [^Matrix4 m (.getTransformMatrix object)
x (float (or x 0))
y (float (or y 0))]
(.setTranslation m x y 0)
(.setTransformMatrix object m)))
(when batch (when batch
(.end ^SpriteBatch batch)) (.end ^SpriteBatch batch))
(when camera (when camera
(.setProjectionMatrix object (. camera combined))) (.setProjectionMatrix object (. camera combined)))
(.begin object type) (.begin object type)
(when angle (when (or x y scale-x scale-y angle)
(let [x (float (or x 0)) (let [x (float (or x 0))
y (float (or y 0)) y (float (or y 0))
origin-x (float (or origin-x (/ (or width 0) 2))) scale-x (float (or scale-x 1))
origin-y (float (or origin-y (/ (or height 0) 2))) scale-y (float (or scale-y 1))
angle (float (or angle 0))] angle (float (or angle 0))]
(.identity object) (.identity object)
(.translate object (+ x origin-x) (+ y origin-y) 0) (.translate object x y 0)
(.scale object scale-x scale-y 1)
(.rotate object 0 0 1 angle))) (.rotate object 0 0 1 angle)))
(draw!) (draw!)
(.end object) (.end object)