From a848ebac324c976a78caf1afcfd4c2bd670ecd4b Mon Sep 17 00:00:00 2001 From: oakes Date: Mon, 6 Jan 2014 00:27:57 -0500 Subject: [PATCH] Add methods and clean up --- src/play_clj/core_2d.clj | 18 +++++++----------- src/play_clj/core_ui.clj | 4 +++- src/play_clj/utils.clj | 4 ++-- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/play_clj/core_2d.clj b/src/play_clj/core_2d.clj index 9d929eb..5062e52 100644 --- a/src/play_clj/core_2d.clj +++ b/src/play_clj/core_2d.clj @@ -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 diff --git a/src/play_clj/core_ui.clj b/src/play_clj/core_ui.clj index 3338964..701d9d3 100644 --- a/src/play_clj/core_ui.clj +++ b/src/play_clj/core_ui.clj @@ -12,4 +12,6 @@ (defn label [text color] - (create-actor (Label. text (Label$LabelStyle. (BitmapFont.) color)))) + (->> (Label$LabelStyle. (BitmapFont.) color) + (Label. text) + create-actor)) diff --git a/src/play_clj/utils.clj b/src/play_clj/utils.clj index 9c46a3a..803d439 100644 --- a/src/play_clj/utils.clj +++ b/src/play_clj/utils.clj @@ -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)) "/")