Set a texture entity's width and height when it is first created
This commit is contained in:
@@ -159,13 +159,10 @@
|
|||||||
(.draw object batch 1))
|
(.draw object batch 1))
|
||||||
|
|
||||||
(defmethod draw-entity! :texture
|
(defmethod draw-entity! :texture
|
||||||
[^SpriteBatch batch {:keys [^TextureRegion object x y width height]}]
|
[^SpriteBatch batch {:keys [^TextureRegion object x y width height]
|
||||||
|
:or {x 0 y 0}}]
|
||||||
(assert object)
|
(assert object)
|
||||||
(let [x (float (or x 0))
|
(.draw batch object (float x) (float y) (float width) (float height)))
|
||||||
y (float (or y 0))
|
|
||||||
width (float (or width (.getRegionWidth object)))
|
|
||||||
height (float (or height (.getRegionHeight object)))]
|
|
||||||
(.draw batch object x y width height)))
|
|
||||||
|
|
||||||
(defn draw! [{:keys [renderer] :as screen} entities]
|
(defn draw! [{:keys [renderer] :as screen} entities]
|
||||||
(assert renderer)
|
(assert renderer)
|
||||||
|
|||||||
@@ -137,8 +137,11 @@
|
|||||||
(defmulti create-entity class)
|
(defmulti create-entity class)
|
||||||
|
|
||||||
(defmethod create-entity TextureRegion
|
(defmethod create-entity TextureRegion
|
||||||
[obj]
|
[^TextureRegion obj]
|
||||||
{:type :texture :object obj})
|
{:type :texture
|
||||||
|
:object obj
|
||||||
|
:width (.getRegionWidth obj)
|
||||||
|
:height (.getRegionHeight obj)})
|
||||||
|
|
||||||
(defmethod create-entity Actor
|
(defmethod create-entity Actor
|
||||||
[obj]
|
[obj]
|
||||||
|
|||||||
Reference in New Issue
Block a user