Use a centralized function to determine how to deal with objects used in entity macros

This commit is contained in:
oakes
2014-01-19 03:37:18 -05:00
parent a17d0ceb79
commit 6bac86a94f
5 changed files with 65 additions and 58 deletions

View File

@@ -14,19 +14,19 @@
(string? arg)
(-> ^String arg Texture. TextureRegion.)
(map? arg)
(TextureRegion. ^TextureRegion (:object arg))
(TextureRegion. ^TextureRegion (u/get-obj arg :object))
:else
arg)))
(defmacro texture
[arg & options]
`(let [entity# (texture* ~arg)]
(u/calls! ^TextureRegion (:object entity#) ~@options)
(u/calls! ^TextureRegion (u/get-obj entity# :object) ~@options)
entity#))
(defmacro texture!
[entity k & options]
`(u/call! ^TextureRegion (:object ~entity) ~k ~@options))
`(u/call! ^TextureRegion (u/get-obj ~entity :object) ~k ~@options))
(defmacro play-mode
[key]
@@ -35,7 +35,7 @@
(defn animation*
[duration textures]
(Animation. duration
(u/gdx-array (map :object textures))
(u/gdx-array (map #(u/get-obj % :object) textures))
(play-mode :normal)))
(defmacro animation