Allow creating new tiled maps, layers, and cells

This commit is contained in:
oakes
2014-04-03 20:39:42 -04:00
parent ef692f4607
commit 57cae0c860

View File

@@ -20,10 +20,12 @@
; tiled maps ; tiled maps
(defn tiled-map* (defn tiled-map*
[s] ([]
(if (string? s) (TiledMap.))
(.load (TmxMapLoader.) s) ([s]
s)) (if (string? s)
(.load (TmxMapLoader.) s)
s)))
(defmacro tiled-map (defmacro tiled-map
"Returns a [TiledMap](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMap.html). "Returns a [TiledMap](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMap.html).
@@ -51,12 +53,14 @@ objects cooresponding to each layer in the tiled map in `screen`.
(.get layers i)))) (.get layers i))))
(defn tiled-map-layer* (defn tiled-map-layer*
[screen layer] ([width height tile-width tile-height]
(if (isa? (type layer) MapLayer) (TiledMapTileLayer. width height tile-width tile-height))
layer ([screen layer]
(->> (tiled-map-layers screen) (if (isa? (type layer) MapLayer)
(drop-while #(not= layer (.getName ^MapLayer %))) layer
first))) (->> (tiled-map-layers screen)
(drop-while #(not= layer (.getName ^MapLayer %)))
first))))
(defmacro tiled-map-layer (defmacro tiled-map-layer
"Returns a [TiledMapTileLayer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMapTileLayer.html) "Returns a [TiledMapTileLayer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMapTileLayer.html)
@@ -83,8 +87,10 @@ tiled map in `screen`."
(tiled-map-layer! layer :get-name))) (tiled-map-layer! layer :get-name)))
(defn tiled-map-cell* (defn tiled-map-cell*
[screen layer x y] ([]
(.getCell ^TiledMapTileLayer (tiled-map-layer screen layer) x y)) (TiledMapTileLayer$Cell.))
([screen layer x y]
(.getCell ^TiledMapTileLayer (tiled-map-layer screen layer) x y)))
(defmacro tiled-map-cell (defmacro tiled-map-cell
"Returns a [TiledMapTileLayer.Cell](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMapTileLayer.Cell.html) "Returns a [TiledMapTileLayer.Cell](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMapTileLayer.Cell.html)