Add methods and clean up

This commit is contained in:
oakes
2014-01-06 00:27:57 -05:00
parent 8e0fdc8ed4
commit a848ebac32
3 changed files with 12 additions and 14 deletions

View File

@@ -4,9 +4,7 @@
(defmulti sprite-batch #(-> % :renderer class) :default nil)
(defmethod sprite-batch nil
[screen]
(SpriteBatch.))
(defmethod sprite-batch nil [_])
(defmethod sprite-batch BatchTiledMapRenderer
[{:keys [^BatchTiledMapRenderer renderer]}]
@@ -20,10 +18,11 @@
[^SpriteBatch batch {:keys [^Actor actor] :as entity}]
(doseq [[k v] entity]
(case k
:x (.setX actor v)
:y (.setY actor v)
:width (.setWidth actor v)
:height (.setHeight actor v)
:x (.setX actor (float v))
:y (.setY actor (float v))
:width (.setWidth actor (float v))
:height (.setHeight actor (float v))
:text (.setText actor (str v))
nil))
(.draw ^Actor actor batch 1))
@@ -67,6 +66,7 @@
:region (.setRegion img
^long (nth v 0) ^long (nth v 1)
^long (nth v 2) ^long (nth v 3))
:flip (.flip img (nth v 0) (nth v 1))
nil))
img))
@@ -84,10 +84,6 @@
([val width height]
(-> val ^TextureRegion image (.split width height))))
(defn flip-image
[val x? y?]
(doto ^TextureRegion (image val) (.flip x? y?)))
(defmacro animation
[duration images & args]
`(Animation. ~duration

View File

@@ -12,4 +12,6 @@
(defn label
[text color]
(create-actor (Label. text (Label$LabelStyle. (BitmapFont.) color))))
(->> (Label$LabelStyle. (BitmapFont.) color)
(Label. text)
create-actor))

View File

@@ -2,7 +2,7 @@
(:require [clojure.string :as s])
(:import [com.badlogic.gdx.utils Array]))
(defn- split-keys
(defn- split-key
[key]
(-> key name (s/split #"-")))
@@ -13,7 +13,7 @@
(defn gdx-static-field*
[args]
(->> (last args)
split-keys
split-key
(map s/upper-case)
(s/join "_")
(str (join-keys (butlast args)) "/")