Add gdx-array-map
This commit is contained in:
@@ -77,7 +77,7 @@
|
|||||||
(defmacro animation
|
(defmacro animation
|
||||||
[duration textures & args]
|
[duration textures & args]
|
||||||
`(Animation. ~duration
|
`(Animation. ~duration
|
||||||
(u/convert-array (map :object ~textures))
|
(u/gdx-array (map :object ~textures))
|
||||||
(u/static-field-upper :graphics :g2d :Animation
|
(u/static-field-upper :graphics :g2d :Animation
|
||||||
~(or (first args) :normal))))
|
~(or (first args) :normal))))
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
(ns play-clj.utils
|
(ns play-clj.utils
|
||||||
(:require [clojure.string :as s])
|
(:require [clojure.string :as s])
|
||||||
(:import [com.badlogic.gdx.graphics.g2d TextureRegion]
|
(:import [com.badlogic.gdx.graphics.g2d TextureRegion]
|
||||||
[com.badlogic.gdx.utils Array]
|
[com.badlogic.gdx.scenes.scene2d Actor]
|
||||||
[com.badlogic.gdx.scenes.scene2d Actor]))
|
[com.badlogic.gdx.utils Array ArrayMap]))
|
||||||
|
|
||||||
|
; converting keys
|
||||||
|
|
||||||
(def ^:const main-package "com.badlogic.gdx")
|
(def ^:const main-package "com.badlogic.gdx")
|
||||||
|
|
||||||
@@ -52,9 +54,20 @@
|
|||||||
[& args]
|
[& args]
|
||||||
`~(static-field args key->upper))
|
`~(static-field args key->upper))
|
||||||
|
|
||||||
(defn convert-array
|
; data structures
|
||||||
[a]
|
|
||||||
(Array. true (into-array a) 1 (count a)))
|
(defn gdx-array
|
||||||
|
[arr]
|
||||||
|
(Array. true (into-array arr) 1 (count arr)))
|
||||||
|
|
||||||
|
(defn gdx-array-map
|
||||||
|
[hmap]
|
||||||
|
(let [amap (ArrayMap.)]
|
||||||
|
(doseq [[k v] hmap]
|
||||||
|
(.put amap k v))
|
||||||
|
amap))
|
||||||
|
|
||||||
|
; java interop
|
||||||
|
|
||||||
(defmacro call!
|
(defmacro call!
|
||||||
[obj k & args]
|
[obj k & args]
|
||||||
@@ -73,6 +86,8 @@
|
|||||||
[obj & args]
|
[obj & args]
|
||||||
`(doto ~obj ~@(create-method-calls [] args)))
|
`(doto ~obj ~@(create-method-calls [] args)))
|
||||||
|
|
||||||
|
; entities
|
||||||
|
|
||||||
(defmulti create-entity class)
|
(defmulti create-entity class)
|
||||||
|
|
||||||
(defmethod create-entity TextureRegion
|
(defmethod create-entity TextureRegion
|
||||||
|
|||||||
Reference in New Issue
Block a user