Add methods and clean up
This commit is contained in:
@@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
(defmulti sprite-batch #(-> % :renderer class) :default nil)
|
(defmulti sprite-batch #(-> % :renderer class) :default nil)
|
||||||
|
|
||||||
(defmethod sprite-batch nil
|
(defmethod sprite-batch nil [_])
|
||||||
[screen]
|
|
||||||
(SpriteBatch.))
|
|
||||||
|
|
||||||
(defmethod sprite-batch BatchTiledMapRenderer
|
(defmethod sprite-batch BatchTiledMapRenderer
|
||||||
[{:keys [^BatchTiledMapRenderer renderer]}]
|
[{:keys [^BatchTiledMapRenderer renderer]}]
|
||||||
@@ -20,10 +18,11 @@
|
|||||||
[^SpriteBatch batch {:keys [^Actor actor] :as entity}]
|
[^SpriteBatch batch {:keys [^Actor actor] :as entity}]
|
||||||
(doseq [[k v] entity]
|
(doseq [[k v] entity]
|
||||||
(case k
|
(case k
|
||||||
:x (.setX actor v)
|
:x (.setX actor (float v))
|
||||||
:y (.setY actor v)
|
:y (.setY actor (float v))
|
||||||
:width (.setWidth actor v)
|
:width (.setWidth actor (float v))
|
||||||
:height (.setHeight actor v)
|
:height (.setHeight actor (float v))
|
||||||
|
:text (.setText actor (str v))
|
||||||
nil))
|
nil))
|
||||||
(.draw ^Actor actor batch 1))
|
(.draw ^Actor actor batch 1))
|
||||||
|
|
||||||
@@ -67,6 +66,7 @@
|
|||||||
:region (.setRegion img
|
:region (.setRegion img
|
||||||
^long (nth v 0) ^long (nth v 1)
|
^long (nth v 0) ^long (nth v 1)
|
||||||
^long (nth v 2) ^long (nth v 3))
|
^long (nth v 2) ^long (nth v 3))
|
||||||
|
:flip (.flip img (nth v 0) (nth v 1))
|
||||||
nil))
|
nil))
|
||||||
img))
|
img))
|
||||||
|
|
||||||
@@ -84,10 +84,6 @@
|
|||||||
([val width height]
|
([val width height]
|
||||||
(-> val ^TextureRegion image (.split width height))))
|
(-> val ^TextureRegion image (.split width height))))
|
||||||
|
|
||||||
(defn flip-image
|
|
||||||
[val x? y?]
|
|
||||||
(doto ^TextureRegion (image val) (.flip x? y?)))
|
|
||||||
|
|
||||||
(defmacro animation
|
(defmacro animation
|
||||||
[duration images & args]
|
[duration images & args]
|
||||||
`(Animation. ~duration
|
`(Animation. ~duration
|
||||||
|
|||||||
@@ -12,4 +12,6 @@
|
|||||||
|
|
||||||
(defn label
|
(defn label
|
||||||
[text color]
|
[text color]
|
||||||
(create-actor (Label. text (Label$LabelStyle. (BitmapFont.) color))))
|
(->> (Label$LabelStyle. (BitmapFont.) color)
|
||||||
|
(Label. text)
|
||||||
|
create-actor))
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
(:require [clojure.string :as s])
|
(:require [clojure.string :as s])
|
||||||
(:import [com.badlogic.gdx.utils Array]))
|
(:import [com.badlogic.gdx.utils Array]))
|
||||||
|
|
||||||
(defn- split-keys
|
(defn- split-key
|
||||||
[key]
|
[key]
|
||||||
(-> key name (s/split #"-")))
|
(-> key name (s/split #"-")))
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
(defn gdx-static-field*
|
(defn gdx-static-field*
|
||||||
[args]
|
[args]
|
||||||
(->> (last args)
|
(->> (last args)
|
||||||
split-keys
|
split-key
|
||||||
(map s/upper-case)
|
(map s/upper-case)
|
||||||
(s/join "_")
|
(s/join "_")
|
||||||
(str (join-keys (butlast args)) "/")
|
(str (join-keys (butlast args)) "/")
|
||||||
|
|||||||
Reference in New Issue
Block a user