relative positioning needs to be based off the scale.

This commit is contained in:
2015-04-22 19:57:18 -07:00
parent d866c00cd9
commit 7495c63d88
2 changed files with 5 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
(defproject play-clj "0.4.5-SNAPSHOT" (defproject play-clj "0.4.5-BRYCE"
:description "A libGDX wrapper for easy cross-platform game development" :description "A libGDX wrapper for easy cross-platform game development"
:url "https://github.com/oakes/play-clj" :url "https://github.com/oakes/play-clj"
:license {:name "Public Domain" :license {:name "Public Domain"

View File

@@ -21,20 +21,22 @@
(defrecord TextureEntity [object] Entity (defrecord TextureEntity [object] Entity
(draw! [{:keys [^TextureRegion object x y width height (draw! [{:keys [^TextureRegion object x y width height
scale-x scale-y angle origin-x origin-y]} scale-x scale-y angle origin-x origin-y something]}
_ _
batch] batch]
(let [x (- (float (or x 0)) (* (float (or origin-x 0.0)) (float (or scale-x 1.0)))) (let [x (- (float (or x 0)) (* (float (or origin-x 0.0)) (float (or scale-x 1.0))))
y (float (or y 0)) y (float (or y 0))
width (float (or width (.getRegionWidth object))) width (float (or width (.getRegionWidth object)))
height (float (or height (.getRegionHeight object)))] height (float (or height (.getRegionHeight object)))]
(if (or scale-x scale-y angle) (if (or scale-x scale-y angle)
(let [scale-x (float (or scale-x 1)) (let [scale-x (float (or scale-x 1))
scale-y (float (or scale-y 1)) scale-y (float (or scale-y 1))
origin-x (float (or origin-x (/ width 2))) origin-x (float (or origin-x (/ width 2)))
origin-y (float (or origin-y (/ height 2))) origin-y (float (or origin-y (/ height 2)))
angle (float (or angle 0))] angle (float (or angle 0))]
(.draw ^Batch batch object x y origin-x origin-y width height (.draw ^Batch batch object x y (* origin-x scale-x) (* origin-y scale-y) width height
scale-x scale-y angle)) scale-x scale-y angle))
(.draw ^Batch batch object x y width height))))) (.draw ^Batch batch object x y width height)))))