Add gdx-array-map

This commit is contained in:
oakes
2014-01-15 15:31:02 -05:00
parent 646d8e0fa1
commit aab718fe95
2 changed files with 21 additions and 6 deletions

View File

@@ -77,7 +77,7 @@
(defmacro animation
[duration textures & args]
`(Animation. ~duration
(u/convert-array (map :object ~textures))
(u/gdx-array (map :object ~textures))
(u/static-field-upper :graphics :g2d :Animation
~(or (first args) :normal))))

View File

@@ -1,8 +1,10 @@
(ns play-clj.utils
(:require [clojure.string :as s])
(: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")
@@ -52,9 +54,20 @@
[& args]
`~(static-field args key->upper))
(defn convert-array
[a]
(Array. true (into-array a) 1 (count a)))
; data structures
(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!
[obj k & args]
@@ -73,6 +86,8 @@
[obj & args]
`(doto ~obj ~@(create-method-calls [] args)))
; entities
(defmulti create-entity class)
(defmethod create-entity TextureRegion