Change docstrings

This commit is contained in:
oakes
2014-03-31 19:57:19 -04:00
parent ed67cef30c
commit c036e36786
13 changed files with 249 additions and 376 deletions

View File

@@ -34,18 +34,15 @@
(load "core_utils")
(defn ^:private reset-changed!
"Internal use only"
[e-atom e-old e-new]
(when (not= e-old e-new)
(compare-and-set! e-atom e-old e-new)))
(defn ^:private wrapper
"Internal use only"
[screen f]
(f))
(defn defscreen*
"Internal use only"
[{:keys [screen entities
on-show on-render on-hide on-pause on-resize on-resume on-timer]
:as options}]
@@ -86,9 +83,7 @@
:input-listeners (global-listeners options execute-fn!)}))
(defmacro defscreen
"Creates vars for all the anonymous functions provided to it, so they can be
replaced by simply reloading the namespace, and creates a var for the symbol `n`
bound to a map containing various important values related to the screen"
"Defines a screen, and creates vars for all the functions inside of it."
[n & {:keys [] :as options}]
`(let [fn-syms# (->> (for [[k# v#] ~options]
[k# (intern *ns* (symbol (str '~n "-" (name k#))) v#)])
@@ -106,7 +101,6 @@ bound to a map containing various important values related to the screen"
(def ~n (defscreen* syms#))))
(defn defgame*
"Internal use only"
[{:keys [on-create]}]
(proxy [Game] []
(create []
@@ -115,15 +109,14 @@ bound to a map containing various important values related to the screen"
(on-create this)))))
(defmacro defgame
"Creates a var for the symbol `n` bound to a [Game](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Game.html)
object"
"Defines a game. This should only be called once."
{:url ""}
[n & {:keys [] :as options}]
`(defonce ~n (defgame* ~options)))
(defn set-screen!
"Creates a [Screen](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Screen.html)
object, sets it as the screen for the `game`, and runs the functions from
`screens` in the order they are provided in
"Creates and displays a screen for the `game` object, using one or more
`screen` maps in the order they were provided.
(set-screen! hello-world main-screen text-screen)"
[^Game game & screens]
@@ -146,9 +139,9 @@ object, sets it as the screen for the `game`, and runs the functions from
(defn update!
"Runs the equivalent of `(swap! screen-atom assoc ...)`, where `screen-atom`
is the atom storing the screen map behind the scenes, and returns the new screen
map
is the atom storing the screen map behind the scenes. Returns the updated
`screen` map.
(update! screen :renderer (stage))"
[{:keys [update-fn!]} & args]
[{:keys [update-fn!] :as screen} & args]
(update-fn! assoc args))

View File

@@ -3,7 +3,7 @@
; graphics
(defn clear!
"Clears the screen with a uniform color, defaulting to black
"Clears the screen with a uniform color, defaulting to black.
(clear!)
(clear! 0.5 0.5 1 1)"
@@ -15,7 +15,7 @@
(.glClear (bit-or GL20/GL_COLOR_BUFFER_BIT GL20/GL_DEPTH_BUFFER_BIT)))))
(defmacro color
"Returns a [Color](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Color.html)
"Returns a [Color](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Color.html).
(color :white)
(color 1 1 1 1)"
@@ -28,49 +28,49 @@
; interop
(defmacro app!
"Calls a single method on [Gdx.app](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Application.html)
"Calls a single method on [Gdx.app](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Application.html).
(app! :error \"MYTAG\" \"An error occurred, so I'm logging it!\")"
[k & options]
`(u/call! ^Application (Gdx/app) ~k ~@options))
(defmacro audio!
"Calls a single method on [Gdx.audio](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Audio.html)
"Calls a single method on [Gdx.audio](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Audio.html).
(audio! :new-audio-recorder 44100 false)"
[k & options]
`(u/call! ^Audio (Gdx/audio) ~k ~@options))
(defmacro files!
"Calls a single method on [Gdx.files](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Files.html)
"Calls a single method on [Gdx.files](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Files.html).
(files! :internal \"image.png\")"
[k & options]
`(u/call! ^Files (Gdx/files) ~k ~@options))
(defmacro gl!
"Calls a single method on [Gdx.gl20](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/GL20.html)
"Calls a single method on [Gdx.gl20](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/GL20.html).
(gl! :gl-create-program)"
[k & options]
`(u/call! ^GL20 (Gdx/gl20) ~k ~@options))
(defmacro graphics!
"Calls a single method on [Gdx.graphics](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Graphics.html)
"Calls a single method on [Gdx.graphics](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Graphics.html).
(graphics! :is-fullscreen)"
[k & options]
`(u/call! ^Graphics (Gdx/graphics) ~k ~@options))
(defmacro input!
"Calls a single method on [Gdx.input](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Input.html)
"Calls a single method on [Gdx.input](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Input.html).
(input! :is-touched)"
[k & options]
`(u/call! ^Input (Gdx/input) ~k ~@options))
(defmacro net!
"Calls a single method on [Gdx.net](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Net.html)
"Calls a single method on [Gdx.net](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Net.html).
(net! :open-uri \"https://nightcode.info/\")"
[k & options]
@@ -79,10 +79,15 @@
; input/output
(defn game
"Calls the global method cooresponding to `k` in a more Clojuresque way
"Provides quick access to often-used functions.
(game :width)
(game :is-touched?)"
(game :width) ; width of the window
(game :height) ; height of the window
(game :fps) ; frames per second
(game :is-fullscreen?) ; whether the window is fullscreen
(game :is-touched?) ; whether the window is being touched/clicked
(game :x) ; the x position of the touch/click
(game :y) ; the y position of the touch/click"
[k]
(case k
:width (graphics! :get-width)
@@ -95,7 +100,7 @@
(u/throw-key-not-found k)))
(defmacro key-code
"Returns a static field from [Input.Keys](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Input.Keys.html)
"Returns a static field from [Input.Keys](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Input.Keys.html).
(key-code :a)
(key-code :page-down)"
@@ -103,7 +108,7 @@
`~(u/gdx-field "Input$Keys" (u/key->upper k)))
(defmacro is-pressed?
"Returns a boolean indicating if the key cooresponding to `k` is being pressed
"Returns a boolean indicating if the key cooresponding to `k` is being pressed.
(is-pressed? :a)
(is-pressed? :page-down)"
@@ -111,26 +116,23 @@
`(input! :is-key-pressed (key-code ~k)))
(defn ^:private add-input!
"Internal use only"
[^InputProcessor p]
(let [^InputMultiplexer multi (input! :get-input-processor)]
(.addProcessor multi p)))
(defn ^:private remove-input!
"Internal use only"
[^InputProcessor p]
(let [^InputMultiplexer multi (input! :get-input-processor)]
(.removeProcessor multi p)))
(defn sound*
"The function version of `sound`"
[path]
(audio! :new-sound (if (string? path)
(files! :internal path)
path)))
(defmacro sound
"Returns a [Sound](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/audio/Sound.html)
"Returns a [Sound](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/audio/Sound.html).
(sound \"playerhurt.wav\")
(sound \"playerhurt.wav\" :play)"
@@ -138,7 +140,7 @@
`(u/calls! ^Sound (sound* ~path) ~@options))
(defmacro sound!
"Calls a single method on a `sound`
"Calls a single method on a `sound`.
(sound! object :play)
(sound! object :dispose)"

View File

@@ -1,12 +1,11 @@
(in-ns 'play-clj.core)
(defn orthographic*
"The function version of `orthographic`"
[]
(OrthographicCamera.))
(defmacro orthographic
"Returns an [OrthographicCamera](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/OrthographicCamera.html)
"Returns an [OrthographicCamera](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/OrthographicCamera.html).
(orthographic)"
[& options]
@@ -14,20 +13,19 @@
(u/calls! object# ~@options)))
(defmacro orthographic!
"Calls a single method on an `orthographic`"
"Calls a single method on an `orthographic`."
[screen k & options]
`(let [^OrthographicCamera object# (u/get-obj ~screen :camera)]
(u/call! object# ~k ~@options)))
(defn perspective*
"The function version of `perspective`"
([]
(PerspectiveCamera.))
([field-of-view viewport-width viewport-height]
(PerspectiveCamera. field-of-view viewport-width viewport-height)))
(defmacro perspective
"Returns an [PerspectiveCamera](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/PerspectiveCamera.html)
"Returns a [PerspectiveCamera](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/PerspectiveCamera.html).
(perspective)"
[fov vw vh & options]
@@ -35,13 +33,13 @@
(u/calls! object# ~@options)))
(defmacro perspective!
"Calls a single method on a `perspective`"
"Calls a single method on a `perspective`."
[screen k & options]
`(let [^PerspectiveCamera object# (u/get-obj ~screen :camera)]
(u/call! object# ~k ~@options)))
(defn size!
"Sets the size of the camera in `screen`
"Sets the size of the camera in `screen`.
(size! screen 480 360)"
[screen width height]
@@ -52,14 +50,14 @@
(defn width!
"Sets the width of the camera in `screen`, adjusting the height so the ratio
remains in tact
remains in tact.
(width! screen 480)"
[screen new-width]
(size! screen new-width (* new-width (/ (game :height) (game :width)))))
(defn width
"Returns the width of the camera in `screen`
"Returns the width of the camera in `screen`.
(width screen)"
[screen]
@@ -68,14 +66,14 @@ remains in tact
(defn height!
"Sets the height of the camera in `screen`, adjusting the width so the ratio
remains in tact
remains in tact.
(height! screen 360)"
[screen new-height]
(size! screen (* new-height (/ (game :width) (game :height))) new-height))
(defn height
"Returns the height of the camera in `screen`
"Returns the height of the camera in `screen`.
(height screen)"
[screen]
@@ -83,46 +81,46 @@ remains in tact
(. camera viewportHeight)))
(defn x!
"Sets only the x position of the camera in `screen`"
"Sets only the x position of the camera in `screen`."
[screen x-val]
(let [^Camera camera (u/get-obj screen :camera)]
(set! (. (. camera position) x) x-val)
(.update camera)))
(defn x
"Returns the x position of the camera in `screen`"
"Returns the x position of the camera in `screen`."
[screen]
(let [^Camera camera (u/get-obj screen :camera)]
(. (. camera position) x)))
(defn y!
"Sets only the y position of the camera in `screen`"
"Sets only the y position of the camera in `screen`."
[screen y-val]
(let [^Camera camera (u/get-obj screen :camera)]
(set! (. (. camera position) y) y-val)
(.update camera)))
(defn y
"Returns the y position of the camera in `screen`"
"Returns the y position of the camera in `screen`."
[screen]
(let [^Camera camera (u/get-obj screen :camera)]
(. (. camera position) y)))
(defn z!
"Sets only the z position of the camera in `screen`"
"Sets only the z position of the camera in `screen`."
[screen z-val]
(let [^Camera camera (u/get-obj screen :camera)]
(set! (. (. camera position) z) z-val)
(.update camera)))
(defn z
"Returns the z position of the camera in `screen`"
"Returns the z position of the camera in `screen`."
[screen]
(let [^Camera camera (u/get-obj screen :camera)]
(. (. camera position) z)))
(defn position!
"Sets the position of the camera in `screen`"
"Sets the position of the camera in `screen`."
([screen pos]
(let [^Camera camera (u/get-obj screen :camera)]
(set! (. camera position) pos)))
@@ -136,46 +134,46 @@ remains in tact
(.update camera))))
(defn position
"Returns the position of the camera in `screen`"
"Returns the position of the camera in `screen`."
[screen]
(let [^Camera camera (u/get-obj screen :camera)]
(. camera position)))
(defn direction!
"Sets the direction of the camera in `screen`"
"Sets the direction of the camera in `screen`."
[screen x y z]
(let [^Camera camera (u/get-obj screen :camera)]
(.lookAt camera x y z)
(.update camera)))
(defn direction
"Returns the direction of the camera in `screen`"
"Returns the direction of the camera in `screen`."
[screen]
(let [^Camera camera (u/get-obj screen :camera)]
(. camera direction)))
(defn near!
"Sets the near clipping plane distance of the camera in `screen`"
"Sets the near clipping plane distance of the camera in `screen`."
[screen n]
(let [^Camera camera (u/get-obj screen :camera)]
(set! (. camera near) n)
(.update camera)))
(defn near
"Returns the near clipping plane distance of the camera in `screen`"
"Returns the near clipping plane distance of the camera in `screen`."
[screen]
(let [^Camera camera (u/get-obj screen :camera)]
(. camera near)))
(defn far!
"Sets the far clipping plane distance of the camera in `screen`"
"Sets the far clipping plane distance of the camera in `screen`."
[screen n]
(let [^Camera camera (u/get-obj screen :camera)]
(set! (. camera far) n)
(.update camera)))
(defn far
"Returns the far clipping plane distance of the camera in `screen`"
"Returns the far clipping plane distance of the camera in `screen`."
[screen]
(let [^Camera camera (u/get-obj screen :camera)]
(. camera far)))

View File

@@ -3,21 +3,19 @@
; tiled maps
(defn tiled-map*
"The function version of `tiled-map`"
[s]
(if (string? s)
(.load (TmxMapLoader.) s)
s))
(defmacro tiled-map
"Returns a [TiledMap](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMap.html)
(normally, you don't need to use this directly, because the *-tiled-map
macros that create the renderers will call this themselves)"
"Returns a [TiledMap](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMap.html).
Normally, you don't need to use this directly."
[s & options]
`(u/calls! ^TiledMap (tiled-map* ~s) ~@options))
(defmacro tiled-map!
"Calls a single method on a `tiled-map`
"Calls a single method on a `tiled-map`.
(tiled-map! screen :get-layers)"
[screen k & options]
@@ -26,7 +24,7 @@ macros that create the renderers will call this themselves)"
(defn tiled-map-layers
"Returns a list with [MapLayer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/MapLayer.html)
objects cooresponding to each layer in the tiled map in `screen`
objects cooresponding to each layer in the tiled map in `screen`.
(tiled-map-layers screen)"
[screen]
@@ -36,7 +34,6 @@ objects cooresponding to each layer in the tiled map in `screen`
(.get layers i))))
(defn tiled-map-layer*
"The function version of `tiled-map-layer`"
[screen layer]
(if (isa? (type layer) MapLayer)
layer
@@ -46,7 +43,7 @@ objects cooresponding to each layer in the tiled map in `screen`
(defmacro tiled-map-layer
"Returns a [TiledMapTileLayer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMapTileLayer.html)
from the tiled map in `screen` that matches `layer`
from the tiled map in `screen` that matches `layer`.
(tiled-map-layer screen \"water\")"
[screen layer & options]
@@ -54,7 +51,7 @@ from the tiled map in `screen` that matches `layer`
(u/calls! object# ~@options)))
(defmacro tiled-map-layer!
"Calls a single method on a `tiled-map-layer`
"Calls a single method on a `tiled-map-layer`.
(tiled-map-layer! (tiled-map-layer screen \"water\")
:set-cell 0 0 nil)"
@@ -63,19 +60,18 @@ from the tiled map in `screen` that matches `layer`
(defn tiled-map-layer-names
"Returns a list with strings cooresponding to the name of each layer in the
tiled map in `screen`"
tiled map in `screen`."
[screen]
(for [layer (tiled-map-layers screen)]
(tiled-map-layer! layer :get-name)))
(defn tiled-map-cell*
"The function version of `tiled-map-cell`"
[screen layer x y]
(.getCell ^TiledMapTileLayer (tiled-map-layer screen layer) x y))
(defmacro tiled-map-cell
"Returns a [TiledMapTileLayer.Cell](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/TiledMapTileLayer.Cell.html)
from the tiled map in `screen` from the given `layer` and position `x` and `y`
from the tiled map in `screen` from the given `layer` and position `x` and `y`.
(tiled-map-cell screen \"water\" 0 0)"
[screen layer x y & options]
@@ -83,7 +79,7 @@ from the tiled map in `screen` from the given `layer` and position `x` and `y`
(u/calls! object# ~@options)))
(defmacro tiled-map-cell!
"Calls a single method on a `tiled-map-cell`
"Calls a single method on a `tiled-map-cell`.
(tiled-map-cell! (tiled-map-cell screen \"water\" 0 0)
:set-rotation 90)"
@@ -91,7 +87,6 @@ from the tiled map in `screen` from the given `layer` and position `x` and `y`
`(u/call! ^TiledMapTileLayer$Cell ~object ~k ~@options))
(defn ^:private tiled-map-prop
"Internal use only"
[screen]
(let [^BatchTiledMapRenderer renderer (u/get-obj screen :renderer)
^MapProperties prop (-> renderer .getMap .getProperties)]
@@ -103,7 +98,7 @@ from the tiled map in `screen` from the given `layer` and position `x` and `y`
(defn screen->isometric
"Returns a copy of the provided map with x/y values converted from screen
to isometric map coordinates
to isometric map coordinates.
(screen->isometric screen {:x 64 :y 32})"
[screen {:keys [x y] :as entity}]
@@ -120,7 +115,7 @@ to isometric map coordinates
(defn isometric->screen
"Returns a copy of the provided map with x/y values converted from isometric
map to screen coordinates
map to screen coordinates.
(isometric->screen screen {:x 2 :y 1})"
[screen {:keys [x y] :as entity}]
@@ -136,13 +131,12 @@ map to screen coordinates
; renderers
(defn orthogonal-tiled-map*
"The function version of `orthogonal-tiled-map`"
[path unit]
(OrthogonalTiledMapRenderer. ^TiledMap (tiled-map* path) ^double unit))
(defmacro orthogonal-tiled-map
"Returns an [OrthogonalTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/OrthogonalTiledMapRenderer.html)
with the tiled map file at `path` and `unit` scale
with the tiled map file at `path` and `unit` scale.
(orthogonal-tiled-map \"level1.tmx\" (/ 1 8))"
[path unit & options]
@@ -150,19 +144,18 @@ with the tiled map file at `path` and `unit` scale
~@options))
(defmacro orthogonal-tiled-map!
"Calls a single method on an `orthogonal-tiled-map`"
"Calls a single method on an `orthogonal-tiled-map`."
[screen k & options]
`(let [^OrthogonalTiledMapRenderer object# (u/get-obj ~screen :renderer)]
(u/call! object# ~k ~@options)))
(defn isometric-tiled-map*
"The function version of `isometric-tiled-map`"
[path unit]
(IsometricTiledMapRenderer. ^TiledMap (tiled-map* path) ^double unit))
(defmacro isometric-tiled-map
"Returns an [IsometricTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/IsometricTiledMapRenderer.html)
with the tiled map file at `path` and `unit` scale
with the tiled map file at `path` and `unit` scale.
(isometric-tiled-map \"level1.tmx\" (/ 1 8))"
[path unit & options]
@@ -170,20 +163,19 @@ with the tiled map file at `path` and `unit` scale
~@options))
(defmacro isometric-tiled-map!
"Calls a single method on an `isometric-tiled-map`"
"Calls a single method on an `isometric-tiled-map`."
[screen k & options]
`(let [^IsometricTiledMapRenderer object# (u/get-obj ~screen :renderer)]
(u/call! object# ~k ~@options)))
(defn isometric-staggered-tiled-map*
"The function version of `isometric-staggered-tiled-map`"
[path unit]
(IsometricStaggeredTiledMapRenderer. ^TiledMap (tiled-map* path)
^double unit))
(defmacro isometric-staggered-tiled-map
"Returns an [IsometricStaggeredTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/IsometricStaggeredTiledMapRenderer.html)
with the tiled map file at `path` and `unit` scale
with the tiled map file at `path` and `unit` scale.
(isometric-staggered-tiled-map \"level1.tmx\" (/ 1 8))"
[path unit & options]
@@ -192,20 +184,19 @@ with the tiled map file at `path` and `unit` scale
~@options))
(defmacro isometric-staggered-tiled-map!
"Calls a single method on an `isometric-staggered-tiled-map`"
"Calls a single method on an `isometric-staggered-tiled-map`."
[screen k & options]
`(let [^IsometricStaggeredTiledMapRenderer object#
(u/get-obj ~screen :renderer)]
(u/call! object# ~k ~@options)))
(defn hexagonal-tiled-map*
"The function version of `hexagonal-tiled-map`"
[path unit]
(HexagonalTiledMapRenderer. ^TiledMap (tiled-map* path) ^double unit))
(defmacro hexagonal-tiled-map
"Returns a [HexagonalTiledMapRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/maps/tiled/renderers/HexagonalTiledMapRenderer.html)
with the tiled map file at `path` and `unit` scale
with the tiled map file at `path` and `unit` scale.
(hexagonal-tiled-map \"level1.tmx\" (/ 1 8))"
[path unit & options]
@@ -213,25 +204,24 @@ with the tiled map file at `path` and `unit` scale
~@options))
(defmacro hexagonal-tiled-map!
"Calls a single method on a `hexagonal-tiled-map`"
"Calls a single method on a `hexagonal-tiled-map`."
[screen k & options]
`(let [^HexagonalTiledMapRenderer object# (u/get-obj ~screen :renderer)]
(u/call! object# ~k ~@options)))
(defn stage*
"The function version of `stage`"
[]
(Stage.))
(defmacro stage
"Returns a [Stage](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Stage.html)
"Returns a [Stage](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Stage.html).
(stage)"
[& options]
`(u/calls! ^Stage (stage*) ~@options))
(defmacro stage!
"Calls a single method on a `stage`"
"Calls a single method on a `stage`."
[screen k & options]
`(let [^Stage object# (u/get-obj ~screen :renderer)]
(u/call! object# ~k ~@options)))
@@ -239,7 +229,6 @@ with the tiled map file at `path` and `unit` scale
; draw
(defmulti draw!
"Internal use only"
(fn [screen _] (-> screen :renderer class)))
(defmethod draw! BatchTiledMapRenderer
@@ -272,7 +261,7 @@ with the tiled map file at `path` and `unit` scale
(defn render-map!
"Calls the tiled-map renderer from `screen`, optionally allowing you to
specify which layers to render with or without
specify which layers to render with or without.
(render-map! screen :with \"water\" \"grass\")
(render-map! screen :without \"desert\" \"rocks\")"
@@ -298,7 +287,7 @@ specify which layers to render with or without
nil)
(defn render-stage!
"Calls the stage renderer from `screen`"
"Calls the stage renderer from `screen`."
[{:keys [^Stage renderer ^Camera camera]}]
(when camera
(.setCamera renderer camera)
@@ -308,7 +297,7 @@ specify which layers to render with or without
(defn render!
"Calls the renderer from `screen` and optionally draws and returns the
`entities`
`entities`.
(render! screen entities)"
([{:keys [renderer] :as screen}]
@@ -322,7 +311,6 @@ specify which layers to render with or without
(draw! screen entities)))
(defn ^:private create-layer
"Internal use only"
[^TiledMapTileLayer layer]
(TiledMapTileLayer. (.getWidth layer)
(.getHeight layer)
@@ -330,13 +318,11 @@ specify which layers to render with or without
(int (.getTileHeight layer))))
(defn ^:private isometric?
"Internal use only"
[{:keys [renderer] :as screen}]
(or (isa? (type renderer) IsometricTiledMapRenderer)
(isa? (type renderer) IsometricStaggeredTiledMapRenderer)))
(defn ^:private split-layer
"Internal use only"
[screen layer-name]
(let [^TiledMapTileLayer l (tiled-map-layer screen layer-name)]
(reduce (fn [layers {:keys [x y] :as map-tile}]
@@ -358,7 +344,7 @@ specify which layers to render with or without
{:x x :y y}))))
(defn render-sorted!
"Draws the supplied tiled-map layers and entities, sorted by latitude
"Draws the supplied tiled-map layers and entities, sorted by latitude.
(render-sorted! screen [\"walls\"] entities)"
[{:keys [^BatchTiledMapRenderer renderer

View File

@@ -3,7 +3,6 @@
; global
(defn ^:private input-processor
"Internal use only"
[{:keys [on-key-down on-key-typed on-key-up on-mouse-moved
on-scrolled on-touch-down on-touch-dragged on-touch-up]}
execute-fn!]
@@ -34,7 +33,6 @@
false)))
(defn ^:private gesture-listener
"Internal use only"
[{:keys [on-fling on-long-press on-pan on-pan-stop on-pinch on-tap on-zoom]}
execute-fn!]
(reify GestureDetector$GestureListener
@@ -65,12 +63,10 @@
false)))
(defn ^:private gesture-detector
"Internal use only"
[options execute-fn!]
(proxy [GestureDetector] [(gesture-listener options execute-fn!)]))
(defn ^:private global-listeners
"Internal use only"
[options execute-fn!]
[(input-processor options execute-fn!)
(gesture-detector options execute-fn!)])
@@ -78,7 +74,6 @@
; ui
(defn ^:private actor-gesture-listener
"Internal use only"
[{:keys [on-ui-fling on-ui-long-press on-ui-pan on-ui-pinch
on-ui-tap on-ui-touch-down on-ui-touch-up on-ui-zoom]}
execute-fn!]
@@ -105,14 +100,12 @@
(execute-fn! on-ui-zoom :event e :initial-distance id :distance d))))
(defn ^:private change-listener
"Internal use only"
[{:keys [on-ui-changed]} execute-fn!]
(proxy [ChangeListener] []
(changed [e a]
(execute-fn! on-ui-changed :event e :actor a))))
(defn ^:private click-listener
"Internal use only"
[{:keys [on-ui-clicked on-ui-enter on-ui-exit
on-ui-touch-down on-ui-touch-dragged on-ui-touch-up]}
execute-fn!]
@@ -132,7 +125,6 @@
(execute-fn! on-ui-touch-up :event e :x x :y y :pointer p :button b))))
(defn ^:private drag-listener
"Internal use only"
[{:keys [on-ui-drag on-ui-drag-start on-ui-drag-stop
on-ui-touch-down on-ui-touch-dragged on-ui-touch-up]}
execute-fn!]
@@ -152,7 +144,6 @@
(execute-fn! on-ui-drag-stop :event e :x x :y y :pointer p))))
(defn ^:private focus-listener
"Internal use only"
[{:keys [on-ui-keyboard-focus-changed on-ui-scroll-focus-changed]}
execute-fn!]
(proxy [FocusListener] []
@@ -162,7 +153,6 @@
(execute-fn! on-ui-scroll-focus-changed :event e :actor a :focused? f))))
(defn ^:private ui-listeners
"Internal use only"
[options execute-fn!]
[(actor-gesture-listener options execute-fn!)
(change-listener options execute-fn!)
@@ -173,7 +163,6 @@
; g2d-physics
(defn ^:private contact-listener
"Internal use only"
[{:keys [on-begin-contact on-end-contact on-post-solve on-pre-solve]} execute-fn!]
(reify ContactListener
(beginContact [this c]
@@ -188,7 +177,6 @@
; update functions
(defn ^:private update-stage!
"Internal use only"
[{:keys [^Stage renderer ui-listeners]} entities]
(doseq [^Actor a (.getActors renderer)]
(.remove a))
@@ -201,7 +189,6 @@
(add-input! renderer))
(defn ^:private update-box-2d!
"Internal use only"
[{:keys [^World world]} entities]
(when-not (.isLocked world)
(let [arr (u/gdx-array [])]
@@ -218,7 +205,6 @@
(.destroyJoint world joint))))))
(defn ^:private update-screen!
"Internal use only"
([{:keys [world g2dp-listener]}]
(when (isa? (type world) World)
(.setContactListener ^World world g2dp-listener)))

View File

@@ -3,42 +3,32 @@
; static fields
(defmacro scaling
"Returns a static field from [Scaling](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Scaling.html)
"Returns a static field from [Scaling](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Scaling.html).
(scaling :fill)
(scaling :fill-x)
(scaling :fill-y)
(scaling :fit)
(scaling :none)
(scaling :stretch)
(scaling :stretch-x)
(scaling :stretch-y)"
(scaling :fill)"
[k]
`~(u/gdx-field :utils :Scaling k))
(defmacro usage
"Returns a static field in [VertexAttributes.Usage](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/VertexAttributes.Usage.html)"
"Returns a static field in [VertexAttributes.Usage](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/VertexAttributes.Usage.html)."
[k]
`~(u/gdx-field :graphics "VertexAttributes$Usage" (u/key->pascal k)))
; timers
(defn ^:private task*
"Internal use only."
[{:keys [execute-fn! on-timer]} id]
(proxy [Timer$Task] []
(run []
(execute-fn! on-timer :id id))))
(defn ^:private timer*
"Internal use only."
[]
(some-> (Class/forName "com.badlogic.gdx.utils.Timer")
(try (catch Exception _))
.newInstance))
(defn ^:private create-and-add-timer!
"Internal use only."
[{:keys [update-fn!] :as screen} id]
(when-let [timer (timer*)]
(update-fn! assoc-in [[:timers id] timer])
@@ -46,7 +36,7 @@
(defn add-timer!
"Returns a [Timer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Timer.html)
that runs the :on-timer function according to the given arguments
that runs the :on-timer function according to the given arguments.
; wait 2 seconds and run once
(add-timer! screen :spawn-enemy 2)
@@ -66,7 +56,7 @@ that runs the :on-timer function according to the given arguments
(defn remove-timer!
"Stops and removes the timer associated with `id`, returning it or nil if not
found"
found."
[{:keys [update-fn!] :as screen} id]
(when-let [timer (get-in screen [:timers id])]
(.stop timer)
@@ -76,7 +66,6 @@ found"
; assets
(defn ^:private loader-init
"Internal use only"
[k]
(cond
(contains? #{:atlas-tmx-map :tmx-map} k)
@@ -87,7 +76,7 @@ found"
(u/gdx :assets :loaders (str (u/key->pascal k) "Loader."))))
(defmacro loader
"Returns a subclass of [AsynchronousAssetLoader](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/loaders/AsynchronousAssetLoader.html)
"Returns a subclass of [AsynchronousAssetLoader](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/loaders/AsynchronousAssetLoader.html).
(loader :atlas-tmx-map \"map.atlas\")
(loader :tmx-map \"map.tmx\")
@@ -104,21 +93,20 @@ found"
(u/calls! object# ~@options)))
(defmacro loader!
"Calls a single method in a subclass of [AsynchronousAssetLoader](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/loaders/AsynchronousAssetLoader.html)
"Calls a single method in a subclass of [AsynchronousAssetLoader](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/loaders/AsynchronousAssetLoader.html).
(loader! object :load \"map.tmx\")"
[object & options]
`(u/call! ~object ~@options))
(defn asset-manager*
"The function version of `asset-manager`"
([]
(AssetManager.))
([resolver]
(AssetManager. resolver)))
(defmacro asset-manager
"Returns an [AssetManager](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/AssetManager.html)
"Returns an [AssetManager](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/AssetManager.html).
(asset-manager)"
[& options]
@@ -126,7 +114,7 @@ found"
(u/calls! object# ~@options)))
(defmacro asset-manager!
"Calls a single method in an `asset-manager`
"Calls a single method in an `asset-manager`.
(asset-manager! object :clear)"
[object k & options]

View File

@@ -6,7 +6,6 @@
[com.badlogic.gdx.scenes.scene2d Actor]))
(defprotocol Entity
"Internal use only"
(draw-entity! [this batch] "Draws the entity"))
(extend-protocol Entity

View File

@@ -7,7 +7,7 @@
ParticleEffectEntity]))
(defmacro bitmap-font
"Returns a [BitmapFont](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/BitmapFont.html)
"Returns a [BitmapFont](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/BitmapFont.html).
(bitmap-font)
(bitmap-font (files! :internal \"default.fnt\"))"
@@ -17,7 +17,6 @@
; texture
(defn texture*
"The function version of `texture`"
[arg]
(TextureEntity.
(cond
@@ -29,7 +28,7 @@
arg)))
(defmacro texture
"Returns an entity based on [TextureRegion](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/TextureRegion.html)
"Returns an entity based on [TextureRegion](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/TextureRegion.html).
(texture \"image.png\")
(texture \"image.png\" :flip true false)
@@ -42,7 +41,7 @@
entity#))
(defmacro texture!
"Calls a single method on a `texture`
"Calls a single method on a `texture`.
(texture! entity :flip true false)
(texture! entity :get-region-width)"
@@ -52,7 +51,6 @@
; nine-patch
(defn nine-patch*
"The function version of `nine-patch`"
[arg]
(NinePatchEntity.
(cond
@@ -68,7 +66,7 @@
arg)))
(defmacro nine-patch
"Returns an entity based on [NinePatch](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/NinePatch.html)
"Returns an entity based on [NinePatch](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/NinePatch.html).
(nine-patch \"image.png\")
(nine-patch \"image.png\" :set-color (color :blue))
@@ -79,7 +77,7 @@
entity#))
(defmacro nine-patch!
"Calls a single method on a `nine-patch`
"Calls a single method on a `nine-patch`.
(nine-patch! entity :set-color (color :blue))
(nine-patch! entity :get-middle-width)"
@@ -89,12 +87,11 @@
; particle-effect
(defn particle-effect*
"The function version of `particle-effect`"
[]
(ParticleEffectEntity. (ParticleEffect.)))
(defmacro particle-effect
"Returns an entity based on [ParticleEffect](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/ParticleEffect.html)
"Returns an entity based on [ParticleEffect](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/ParticleEffect.html).
(particle-effect :load
(files! :internal \"fire.p\")
@@ -105,7 +102,7 @@
entity#))
(defmacro particle-effect!
"Calls a single method on a `particle-effect`
"Calls a single method on a `particle-effect`.
(particle-effect! entity :set-position 10 10)"
[entity k & options]
@@ -114,12 +111,11 @@
; texture-atlas
(defn texture-atlas*
"The function version of `texture-atlas`"
[^String path]
(TextureAtlas. path))
(defmacro texture-atlas
"Returns a [TextureAtlas](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/TextureAtlas.html)
"Returns a [TextureAtlas](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/TextureAtlas.html).
(texture-atlas \"packed.txt\")"
[path & options]
@@ -128,7 +124,7 @@
object#))
(defmacro texture-atlas!
"Calls a single method on a `texture-atlas`
"Calls a single method on a `texture-atlas`.
(texture-atlas! object :create-patch \"test\")"
[object k & options]
@@ -137,26 +133,20 @@
; animation
(defmacro play-mode
"Returns a static field from [Animation](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/Animation.html)
"Returns a static field from [Animation](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/Animation.html).
(play-mode :loop)
(play-mode :loop-pingpong)
(play-mode :loop-random)
(play-mode :loop-reversed)
(play-mode :normal)
(play-mode :reversed)"
(play-mode :loop)"
[k]
`~(u/gdx-field :graphics :g2d :Animation (u/key->upper k)))
(defn animation*
"The function version of `animation`"
[duration textures]
(Animation. duration
(u/gdx-array (map #(u/get-obj % :object) textures))
(play-mode :normal)))
(defmacro animation
"Returns an [Animation](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/Animation.html)
"Returns an [Animation](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/Animation.html).
(animation 0.2
[walk-1 walk-2 walk-3]
@@ -165,7 +155,7 @@
`(u/calls! ^Animation (animation* ~duration ~textures) ~@options))
(defmacro animation!
"Calls a single method on an `animation`
"Calls a single method on an `animation`.
(animation! object :set-play-mode (play-mode :loop))"
[object k & options]
@@ -173,7 +163,7 @@
(defn animation->texture
"Returns a `texture` entity with a frame from `animation` based on the total
time the `screen` has been showing
time the `screen` has been showing.
(animation->texture screen anim)"
([{:keys [total-time]} ^Animation animation]

View File

@@ -8,7 +8,6 @@
; world
(defn box-2d*
"The function version of `box-2d`"
([]
(box-2d* 0 0 true))
([gravity-x gravity-y]
@@ -17,7 +16,7 @@
(World. (m/vector-2 gravity-x gravity-y) sleep?)))
(defmacro box-2d
"Returns a [World](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/World.html)
"Returns a [World](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/World.html).
(box-2d 0 0)"
[gravity-x gravity-y & options]
@@ -25,7 +24,7 @@
(u/calls! object# ~@options)))
(defmacro box-2d!
"Calls a single method on a `box-2d`"
"Calls a single method on a `box-2d`."
[screen k & options]
`(let [^World object# (u/get-obj ~screen :world)]
(u/call! object# ~k ~@options)))
@@ -33,13 +32,12 @@
; bodies
(defn ^:private body-type
"Internal use only"
[k]
(u/gdx-class :physics :box2d :BodyDef
(str "BodyType/" (u/key->pascal k) "Body")))
(defmacro body-def
"Returns a [BodyDef](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/BodyDef.html)
"Returns a [BodyDef](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/BodyDef.html).
(body-def :dynamic)"
[k & options]
@@ -48,67 +46,65 @@
(u/fields! object# ~@options)))
(defmacro body!
"Calls a single method on a body"
"Calls a single method on a body."
[entity k & options]
`(let [^Body object# (u/get-obj ~entity :body)]
(u/call! object# ~k ~@options)))
(defn create-body!*
"The function version of `create-body!`"
[screen b-def]
(box-2d! screen :create-body b-def))
(defmacro create-body!
"Returns a [Body](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Body.html)"
"Returns a [Body](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Body.html)."
[screen b-def & options]
`(let [^Body object# (create-body!* ~screen ~b-def)]
(u/calls! object# ~@options)))
(defn body-x
"Returns the x position of the body in `entity`"
"Returns the x position of the body in `entity`."
[entity]
(. (body! entity :get-position) x))
(defn body-y
"Returns the y position of the body in `entity`"
"Returns the y position of the body in `entity`."
[entity]
(. (body! entity :get-position) y))
(defn body-angle
"Returns the angle of the body in `entity`"
"Returns the angle of the body in `entity`."
[entity]
(.getRotation ^Transform (body! entity :get-transform)))
(defn body-transform!
"Changes the `x`, `y`, and `angle` of the body in `entity`"
"Changes the `x`, `y`, and `angle` of the body in `entity`."
[entity x y angle]
(body! entity :set-transform x y angle)
entity)
(defn body-x!
"Changes the `x` of the body in `entity`"
"Changes the `x` of the body in `entity`."
[entity x]
(body-transform! entity x (body-y entity) (body-angle entity)))
(defn body-y!
"Changes the `y` of the body in `entity`"
"Changes the `y` of the body in `entity`."
[entity y]
(body-transform! entity (body-x entity) y (body-angle entity)))
(defn body-angle!
"Changes the `angle` of the body in `entity`"
"Changes the `angle` of the body in `entity`."
[entity angle]
(body-transform! entity (body-x entity) (body-y entity) angle))
; joints
(defn ^:private joint-init
"Internal use only"
[k]
(u/gdx :physics :box2d :joints (str (u/key->pascal k) "JointDef.")))
(defmacro joint-def
"Returns a subclass of [JointDef](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/JointDef.html)
"Returns a subclass of [JointDef](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/JointDef.html).
(joint-def :rope)"
[k & options]
@@ -116,17 +112,16 @@
(u/fields! object# ~@options)))
(defmacro joint!
"Calls a single method on a joint"
"Calls a single method on a joint."
[object k & options]
`(u/call! ^Joint ~object ~k ~@options))
(defn create-joint!*
"The function version of `create-joint!`"
[screen j-def]
(box-2d! screen :create-joint j-def))
(defmacro create-joint!
"Returns a [Joint](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Joint.html)"
"Returns a [Joint](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Joint.html)."
[screen j-def & options]
`(let [object# (create-joint!* ~screen ~j-def)]
(u/calls! object# ~@options)))
@@ -134,36 +129,34 @@
; fixtures
(defmacro fixture-def
"Returns a [FixtureDef](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/FixtureDef.html)"
"Returns a [FixtureDef](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/FixtureDef.html)."
[& options]
`(let [^FixtureDef object# (FixtureDef.)]
(u/fields! object# ~@options)
object#))
(defmacro fixture!
"Calls a single method on a fixture"
"Calls a single method on a fixture."
[object k & options]
`(u/call! ^Fixture ~object ~k ~@options))
; shapes
(defn chain-shape*
"The function version of `chain-shape`"
[]
(ChainShape.))
(defmacro chain-shape
"Returns a [ChainShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/ChainShape.html)"
"Returns a [ChainShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/ChainShape.html)."
[& options]
`(u/calls! ^ChainShape (chain-shape*) ~@options))
(defmacro chain-shape!
"Calls a single method on a `chain-shape`"
"Calls a single method on a `chain-shape`."
[object k & options]
`(u/call! ^ChainShape ~object ~k ~@options))
(defn circle-shape*
"The function version of `circle-shape`"
([]
(CircleShape.))
([radius]
@@ -172,66 +165,64 @@
(.setPosition (m/vector-2 radius radius)))))
(defmacro circle-shape
"Returns a [CircleShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/CircleShape.html)"
"Returns a [CircleShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/CircleShape.html)."
[radius & options]
`(u/calls! ^CircleShape (circle-shape* ~radius) ~@options))
(defmacro circle-shape!
"Calls a single method on a `circle-shape`"
"Calls a single method on a `circle-shape`."
[object k & options]
`(u/call! ^CircleShape ~object ~k ~@options))
(defn edge-shape*
"The function version of `edge-shape`"
[]
(EdgeShape.))
(defmacro edge-shape
"Returns an [EdgeShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/EdgeShape.html)"
"Returns an [EdgeShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/EdgeShape.html)."
[& options]
`(u/calls! ^EdgeShape (edge-shape*) ~@options))
(defmacro edge-shape!
"Calls a single method on an `edge-shape`"
"Calls a single method on an `edge-shape`."
[object k & options]
`(u/call! ^EdgeShape ~object ~k ~@options))
(defn polygon-shape*
"The function version of `polygon-shape`"
[]
(PolygonShape.))
(defmacro polygon-shape
"Returns a [PolygonShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/PolygonShape.html)"
"Returns a [PolygonShape](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/PolygonShape.html)."
[& options]
`(u/calls! ^PolygonShape (polygon-shape*) ~@options))
(defmacro polygon-shape!
"Calls a single method on a `polygon-shape`"
"Calls a single method on a `polygon-shape`."
[object k & options]
`(u/call! ^PolygonShape ~object ~k ~@options))
; misc
(defmacro contact!
"Calls a single method on a [Contact](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Contact.html)"
"Calls a single method on a [Contact](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Contact.html)."
[screen k & options]
`(u/call! ^Contact (u/get-obj ~screen :contact) ~k ~@options))
(defn find-body
"Returns the first entity in `entities` whose body matches `body`"
"Returns the first entity in `entities` whose body matches `body`."
[body entities]
(some #(if (= body (:body %)) %) entities))
(defn first-body
"Returns the first body in a contact"
"Returns the first body in a contact."
[screen]
(let [^Contact contact (u/get-obj screen :contact)]
(assert contact)
(-> contact .getFixtureA .getBody)))
(defn second-body
"Returns the second body in a contact"
"Returns the second body in a contact."
[screen]
(let [^Contact contact (u/get-obj screen :contact)]
(assert contact)

View File

@@ -13,12 +13,11 @@
; animation-controller
(defn animation-controller*
"The function version of `animation-controller`"
[entity]
(AnimationController. (u/get-obj entity :object)))
(defmacro animation-controller
"Returns an [AnimationController](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/utils/AnimationController.html)
"Returns an [AnimationController](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/utils/AnimationController.html).
(animation-controller model-entity)"
[entity & options]
@@ -26,7 +25,7 @@
(u/calls! object# ~@options)))
(defmacro animation-controller!
"Calls a single method on an `animation-controller`"
"Calls a single method on an `animation-controller`."
[object k & options]
`(let [^AnimationController object# ~object]
(u/call! object# ~k ~@options)))
@@ -34,12 +33,11 @@
; environment
(defn environment*
"The function version of `environment`"
[]
(Environment.))
(defmacro environment
"Returns an [Environment](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Environment.html)
"Returns an [Environment](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Environment.html).
(environment)"
[& options]
@@ -47,7 +45,7 @@
(u/calls! object# ~@options)))
(defmacro environment!
"Calls a single method on an `environment`"
"Calls a single method on an `environment`."
[screen k & options]
`(let [^Environment object# (u/get-obj ~screen :attributes)]
(u/call! object# ~k ~@options)))
@@ -55,12 +53,11 @@
; model-batch
(defn model-batch*
"The function version of `model-batch`"
[]
(ModelBatch.))
(defmacro model-batch
"Returns a [ModelBatch](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/ModelBatch.html)
"Returns a [ModelBatch](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/ModelBatch.html).
(model-batch)"
[& options]
@@ -68,7 +65,7 @@
(u/calls! object# ~@options)))
(defmacro model-batch!
"Calls a single method on a `model-batch`"
"Calls a single method on a `model-batch`."
[screen k & options]
`(let [^ModelBatch object# (u/get-obj ~screen :renderer)]
(u/call! object# ~k ~@options)))
@@ -76,7 +73,7 @@
; model
(defmacro model
"Returns an entity based on [ModelInstance](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/ModelInstance.html)"
"Returns an entity based on [ModelInstance](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/ModelInstance.html)."
[& args]
`(ModelEntity.
(let [arg1# ~(first args)]
@@ -89,7 +86,7 @@
(ModelInstance. ~@args)))))
(defmacro model!
"Calls a single method on a `model`"
"Calls a single method on a `model`."
[entity k & options]
`(let [^ModelInstance object# (u/get-obj ~entity :object)]
(u/call! object# ~k ~@options)))
@@ -97,12 +94,11 @@
; model-builder
(defn model-builder*
"The function version of `model-builder`"
[]
(ModelBuilder.))
(defmacro model-builder
"Returns a [ModelBuilder](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/utils/ModelBuilder.html)
"Returns a [ModelBuilder](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/utils/ModelBuilder.html).
(model-builder)"
[& options]
@@ -110,19 +106,18 @@
(u/calls! object# ~@options)))
(defmacro model-builder!
"Calls a single method on a `model-builder`"
"Calls a single method on a `model-builder`."
[object k & options]
`(u/call! ^ModelBuilder ~object ~k ~@options))
; material
(defn material*
"The function version of `material`"
[]
(Material.))
(defmacro material
"Returns a [Material](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Material.html)
"Returns a [Material](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Material.html).
(material)"
[& options]
@@ -130,26 +125,25 @@
(u/calls! object# ~@options)))
(defmacro material!
"Calls a single method on a `material`"
"Calls a single method on a `material`."
[object k & options]
`(u/call! ^Material ~object ~k ~@options))
; attribute
(defn ^:private attribute-init
"Internal use only"
[k]
(u/gdx :graphics :g3d :attributes (str (u/key->pascal k) "Attribute.")))
(defmacro attribute
"Returns a subclass of [Attribute](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Attribute.html)
"Returns a subclass of [Attribute](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Attribute.html).
(attribute :color (attribute-type :color :diffuse) (color :blue))"
[type & args]
`(~(attribute-init type) ~@args))
(defmacro attribute-type
"Returns a static field in a subclass of [Attribute](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Attribute.html)
"Returns a static field in a subclass of [Attribute](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Attribute.html).
(attribute-type :color :diffuse)"
[type k]
@@ -158,7 +152,7 @@
(u/key->pascal k)))
(defmacro attribute!
"Calls a static method in a subclass of [Attribute](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Attribute.html)
"Calls a static method in a subclass of [Attribute](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g3d/Attribute.html).
(attribute! :color :create-diffuse (color :blue))"
[type k & options]

View File

@@ -9,33 +9,33 @@
; static methods/fields
(defmacro geometry!
"Calls a single static method on [GeometryUtils](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/GeometryUtils.html)"
"Calls a single static method on [GeometryUtils](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/GeometryUtils.html)."
[k & options]
`(~(u/gdx-field :math :GeometryUtils (u/key->camel k)) ~@options))
(defmacro interpolation
"Returns a static class in [Interpolation](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Interpolation.html)
"Returns a static class in [Interpolation](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Interpolation.html).
(interpolation :bounce)"
[k]
`~(u/gdx-class :math :Interpolation (u/key->pascal k)))
(defmacro intersector!
"Calls a single static method on [Intersector](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Intersector.html)
"Calls a single static method on [Intersector](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Intersector.html).
(intersector! :is-point-in-triangle 0 1 0 0 1 2 3 0)"
[k & options]
`(~(u/gdx-field :math :Intersector (u/key->camel k)) ~@options))
(defmacro math!
"Calls a single static method on [MathUtils](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/MathUtils.html)
"Calls a single static method on [MathUtils](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/MathUtils.html).
(math! :ceil 0.1)"
[k & options]
`(~(u/gdx-field :math :MathUtils (u/key->camel k)) ~@options))
(defmacro plane-side
"Returns a static field in [Plane.PlaneSide](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Plane.PlaneSide.html)
"Returns a static field in [Plane.PlaneSide](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Plane.PlaneSide.html).
(plane-side :back)"
[k]
@@ -44,418 +44,395 @@
; bezier
(defn bezier*
"The function version of `bezier`"
([]
(Bezier.))
([points]
(Bezier. (into-array points) 0 (count points))))
(defmacro bezier
"Returns a [Bezier](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Bezier.html)"
"Returns a [Bezier](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Bezier.html)."
[points & options]
`(u/calls! ^Bezier (bezier* ~points) ~@options))
(defmacro bezier!
"Calls a single method on a `bezier`"
"Calls a single method on a `bezier`."
[object k & options]
`(u/call! ^Bezier ~object ~k ~@options))
; bresenham2
(defn bresenham-2*
"The function version of `bresenham-2`"
[]
(Bresenham2.))
(defmacro bresenham-2
"Returns a [Bresenham2](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Bresenham2.html)"
"Returns a [Bresenham2](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Bresenham2.html)."
[& options]
`(u/calls! ^Bresenham2 (bresenham-2*) ~@options))
(defmacro bresenham-2!
"Calls a single method on a `bresenham-2`"
"Calls a single method on a `bresenham-2`."
[object k & options]
`(u/call! ^Bresenham2 ~object ~k ~@options))
; b-spline
(defn b-spline*
"The function version of `b-spline`"
([]
(BSpline.))
([points degree cont?]
(BSpline. (into-array points) degree cont?)))
(defmacro b-spline
"Returns a [BSpline](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/BSpline.html)"
"Returns a [BSpline](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/BSpline.html)."
[points degree cont? & options]
`(u/calls! ^BSpline (b-spline* ~points ~degree ~cont?) ~@options))
(defmacro b-spline!
"Calls a single method on a `b-spline`"
"Calls a single method on a `b-spline`."
[object k & options]
`(u/call! ^BSpline ~object ~k ~@options))
; catmull-rom-spline
(defn catmull-rom-spline*
"The function version of `catmull-rom-spline`"
([]
(CatmullRomSpline.))
([points cont?]
(CatmullRomSpline. (into-array points) cont?)))
(defmacro catmull-rom-spline
"Returns a [CatmullRomSpline](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/CatmullRomSpline.html)"
"Returns a [CatmullRomSpline](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/CatmullRomSpline.html)."
[points cont? & options]
`(u/calls! ^CatmullRomSpline (catmull-rom-spline* ~points ~cont?) ~@options))
(defmacro catmull-rom-spline!
"Calls a single method on a `catmull-rom-spline`"
"Calls a single method on a `catmull-rom-spline`."
[object k & options]
`(u/call! ^CatmullRomSpline ~object ~k ~@options))
; circle
(defn circle*
"The function version of `circle`"
([]
(Circle.))
([x y radius]
(Circle. x y radius)))
(defmacro circle
"Returns a [Circle](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Circle.html)"
"Returns a [Circle](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Circle.html)."
[x y radius & options]
`(u/calls! ^Circle (circle* ~x ~y ~radius) ~@options))
(defmacro circle!
"Calls a single method on a `circle`"
"Calls a single method on a `circle`."
[object k & options]
`(u/call! ^Circle ~object ~k ~@options))
; convex-hull
(defn convex-hull*
"The function version of `convex-hull`"
[]
(ConvexHull.))
(defmacro convex-hull
"Returns a [ConvexHull](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/ConvexHull.html)"
"Returns a [ConvexHull](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/ConvexHull.html)."
[& options]
`(u/calls! ^ConvexHull (convex-hull*) ~@options))
(defmacro convex-hull!
"Calls a single method on a `convex-hull`"
"Calls a single method on a `convex-hull`."
[object k & options]
`(u/call! ^ConvexHull ~object ~k ~@options))
; delaunay-triangulator
(defn delaunay-triangulator*
"The function version of `delaunay-triangulator`"
[]
(DelaunayTriangulator.))
(defmacro delaunay-triangulator
"Returns a [DelaunayTriangulator](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/DelaunayTriangulator.html)"
"Returns a [DelaunayTriangulator](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/DelaunayTriangulator.html)."
[& options]
`(u/calls! ^DelaunayTriangulator (delaunay-triangulator*) ~@options))
(defmacro delaunay-triangulator!
"Calls a single method on a `delaunay-triangulator`"
"Calls a single method on a `delaunay-triangulator`."
[object k & options]
`(u/call! ^DelaunayTriangulator ~object ~k ~@options))
; ear-clipping-triangulator
(defn ear-clipping-triangulator*
"The function version of `ear-clipping-triangulator`"
[]
(EarClippingTriangulator.))
(defmacro ear-clipping-triangulator
"Returns an [EarClippingTriangulator](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/EarClippingTriangulator.html)"
"Returns an [EarClippingTriangulator](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/EarClippingTriangulator.html)."
[& options]
`(u/calls! ^EarClippingTriangulator (ear-clipping-triangulator*) ~@options))
(defmacro ear-clipping-triangulator!
"Calls a single method on a `ear-clipping-triangulator`"
"Calls a single method on a `ear-clipping-triangulator`."
[object k & options]
`(u/call! ^EarClippingTriangulator ~object ~k ~@options))
; ellipse
(defn ellipse*
"The function version of `ellipse`"
([]
(Ellipse.))
([x y width height]
(Ellipse. x y width height)))
(defmacro ellipse
"Returns an [Ellipse](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Ellipse.html)"
"Returns an [Ellipse](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Ellipse.html)."
[x y width height & options]
`(u/calls! ^Ellipse (ellipse* ~x ~y ~width ~height) ~@options))
(defmacro ellipse!
"Calls a single method on an `ellipse`"
"Calls a single method on an `ellipse`."
[object k & options]
`(u/call! ^Ellipse ~object ~k ~@options))
; float-counter
(defn float-counter*
"The function version of `float-counter`"
[window-size]
(FloatCounter. window-size))
(defmacro float-counter
"Returns a [FloatCounter](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/FloatCounter.html)"
"Returns a [FloatCounter](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/FloatCounter.html)."
[window-size & options]
`(u/calls! ^FloatCounter (float-counter* ~window-size) ~@options))
(defmacro float-counter!
"Calls a single method on a `float-counter`"
"Calls a single method on a `float-counter`."
[object k & options]
`(u/call! ^FloatCounter ~object ~k ~@options))
; frustum
(defn frustum*
"The function version of `frustum`"
[]
(Frustum.))
(defmacro frustum
"Returns a [Frustum](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Frustum.html)"
"Returns a [Frustum](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Frustum.html)."
[& options]
`(u/calls! ^Frustum (frustum*) ~@options))
(defmacro frustum!
"Calls a single method on a `frustum`"
"Calls a single method on a `frustum`."
[object k & options]
`(u/call! ^Frustum ~object ~k ~@options))
; grid-point-2
(defn grid-point-2*
"The function version of `grid-point-2`"
[x y]
(GridPoint2. x y))
(defmacro grid-point-2
"Returns a [GridPoint2](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/GridPoint2.html)"
"Returns a [GridPoint2](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/GridPoint2.html)."
[x y & options]
`(u/calls! ^GridPoint2 (grid-point-2* ~x ~y) ~@options))
(defmacro grid-point-2!
"Calls a single method on a `grid-point-2`"
"Calls a single method on a `grid-point-2`."
[object k & options]
`(u/call! ^GridPoint2 ~object ~k ~@options))
; grid-point-3
(defn grid-point-3*
"The function version of `grid-point-3`"
[x y z]
(GridPoint3. x y z))
(defmacro grid-point-3
"Returns a [GridPoint3](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/GridPoint3.html)"
"Returns a [GridPoint3](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/GridPoint3.html)."
[x y z & options]
`(u/calls! ^GridPoint3 (grid-point-3* ~x ~y ~z) ~@options))
(defmacro grid-point-3!
"Calls a single method on a `grid-point-3`"
"Calls a single method on a `grid-point-3`."
[object k & options]
`(u/call! ^GridPoint3 ~object ~k ~@options))
; matrix-3
(defn matrix-3*
"The function version of `matrix-3`"
([]
(Matrix3.))
([values]
(Matrix3. values)))
(defmacro matrix-3
"Returns a [Matrix3](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Matrix3.html)"
"Returns a [Matrix3](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Matrix3.html)."
[values & options]
`(u/calls! ^Matrix3 (matrix-3* ~values) ~@options))
(defmacro matrix-3!
"Calls a single method on a `matrix-3`"
"Calls a single method on a `matrix-3`."
[object k & options]
`(u/call! ^Matrix3 ~object ~k ~@options))
; matrix-4
(defn matrix-4*
"The function version of `matrix-4`"
([]
(Matrix4.))
([^floats values]
(Matrix4. values)))
(defmacro matrix-4
"Returns a [Matrix4](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Matrix4.html)"
"Returns a [Matrix4](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Matrix4.html)."
[values & options]
`(u/calls! ^Matrix4 (matrix-4* ~values) ~@options))
(defmacro matrix-4!
"Calls a single method on a `matrix-4`"
"Calls a single method on a `matrix-4`."
[object k & options]
`(u/call! ^Matrix4 ~object ~k ~@options))
; plane
(defn plane*
"The function version of `plane`"
([arg1 arg2]
(Plane. arg1 arg2))
([^Vector3 p1 ^Vector3 p2 ^Vector3 p3]
(Plane. p1 p2 p3)))
(defmacro plane
"Returns a [Plane](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Plane.html)"
"Returns a [Plane](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Plane.html)."
[args & options]
`(u/calls! ^Plane (apply plane* ~args) ~@options))
(defmacro plane!
"Calls a single method on a `plane`"
"Calls a single method on a `plane`."
[object k & options]
`(u/call! ^Plane ~object ~k ~@options))
; polygon
(defn polygon*
"The function version of `polygon`"
([]
(Polygon.))
([vertices]
(Polygon. vertices)))
(defmacro polygon
"Returns a [Polygon](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Polygon.html)"
"Returns a [Polygon](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Polygon.html)."
[vertices & options]
`(u/calls! ^Polygon (polygon* ~vertices) ~@options))
(defmacro polygon!
"Calls a single method on a `polygon`"
"Calls a single method on a `polygon`."
[object k & options]
`(u/call! ^Polygon ~object ~k ~@options))
; polyline
(defn polyline*
"The function version of `polyline`"
([]
(Polyline.))
([vertices]
(Polyline. vertices)))
(defmacro polyline
"Returns a [Polyline](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Polyline.html)"
"Returns a [Polyline](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Polyline.html)."
[vertices & options]
`(u/calls! ^Polyline (polyline* ~vertices) ~@options))
(defmacro polyline!
"Calls a single method on a `polyline`"
"Calls a single method on a `polyline`."
[object k & options]
`(u/call! ^Polyline ~object ~k ~@options))
; quaternion
(defn quaternion*
"The function version of `quaternion`"
([]
(Quaternion.))
([w x y z]
(Quaternion. w x y z)))
(defmacro quaternion
"Returns a [Quaternion](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Quaternion.html)"
"Returns a [Quaternion](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Quaternion.html)."
[w x y z & options]
`(u/calls! ^Quaternion (quaternion* ~w ~x ~y ~z) ~@options))
(defmacro quaternion!
"Calls a single method on a `quaternion`"
"Calls a single method on a `quaternion`."
[object k & options]
`(u/call! ^Quaternion ~object ~k ~@options))
; rectangle
(defn rectangle*
"The function version of `rectangle`"
([]
(Rectangle.))
([x y width height]
(Rectangle. x y width height)))
(defmacro rectangle
"Returns a [Rectangle](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Rectangle.html)"
"Returns a [Rectangle](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Rectangle.html)."
[x y width height & options]
`(u/calls! ^Rectangle (rectangle* ~x ~y ~width ~height) ~@options))
(defmacro rectangle!
"Calls a single method on a `rectangle`"
"Calls a single method on a `rectangle`."
[object k & options]
`(u/call! ^Rectangle ~object ~k ~@options))
; vector-2
(defn vector-2*
"The function version of `vector-2`"
([]
(Vector2.))
([x y]
(Vector2. x y)))
(defmacro vector-2
"Returns a [Vector2](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Vector2.html)"
"Returns a [Vector2](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Vector2.html)."
[x y & options]
`(u/calls! ^Vector2 (vector-2* ~x ~y) ~@options))
(defmacro vector-2!
"Calls a single method on a `vector-2`"
"Calls a single method on a `vector-2`."
[object k & options]
`(u/call! ^Vector2 ~object ~k ~@options))
; vector-3
(defn vector-3*
"The function version of `vector-3`"
([]
(Vector3.))
([x y z]
(Vector3. x y z)))
(defmacro vector-3
"Returns a [Vector3](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Vector3.html)"
"Returns a [Vector3](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Vector3.html)."
[x y z & options]
`(u/calls! ^Vector3 (vector-3* ~x ~y ~z) ~@options))
(defmacro vector-3!
"Calls a single method on a `vector-3`"
"Calls a single method on a `vector-3`."
[object k & options]
`(u/call! ^Vector3 ~object ~k ~@options))
; windowed-mean
(defn windowed-mean*
"The function version of `windowed-mean`"
[window-size]
(WindowedMean. window-size))
(defmacro windowed-mean
"Returns a [WindowedMean](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/WindowedMean.html)"
"Returns a [WindowedMean](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/WindowedMean.html)."
[window-size & options]
`(u/calls! ^WindowedMean (windowed-mean* ~window-size) ~@options))
(defmacro windowed-mean!
"Calls a single method on a `windowed-mean`"
"Calls a single method on a `windowed-mean`."
[object k & options]
`(u/call! ^WindowedMean ~object ~k ~@options))

View File

@@ -15,7 +15,7 @@
[play_clj.entities ActorEntity]))
(defmacro drawable
"Returns a subclass of [BaseDrawable](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/BaseDrawable.html)
"Returns a subclass of [BaseDrawable](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/BaseDrawable.html).
(drawable :texture-region)"
[k & options]
@@ -24,7 +24,7 @@
~@options))
(defmacro style
"Returns a style object whose class is determined by the keyword `k`
"Returns a style object whose class is determined by the keyword `k`.
(style :check-box)"
[k & options]
@@ -35,22 +35,21 @@
(defmacro skin
"Returns a [Skin](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Skin.html)
based on the file at `path`
based on the file at `path`.
(skin \"uiskin.json\")"
[path & options]
`(u/calls! ^Skin (Skin. (.internal ^Files (Gdx/files) ~path)) ~@options))
(defmacro align
"Returns a static field from [Align](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/Align.html)
"Returns a static field from [Align](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/Align.html).
(align :center)"
[k]
`~(u/gdx-field :scenes :scene2d :utils :Align (u/key->camel k)))
(defn cell!
"Calls a single method on a [Cell](https://github.com/libgdx/libgdx/blob/master/gdx/src/com/esotericsoftware/tablelayout/Cell.java)
(this could probably be made into a macro...)"
"Calls a single method on a [Cell](https://github.com/libgdx/libgdx/blob/master/gdx/src/com/esotericsoftware/tablelayout/Cell.java)."
[^Cell cell & args]
(let [method (first args)
[[a1 a2 a3 a4] rest-args] (split-with #(not (keyword? %)) (rest args))]
@@ -98,16 +97,13 @@ based on the file at `path`
cell))
(defmulti add-to-group!
"Internal use only"
#(-> % first :object type) :default WidgetGroup)
(defn ^:private create-tree-node
"Internal use only"
[child]
{:object (Tree$Node. ^Actor (:object child))})
(defn ^:private add-tree-nodes
"Internal use only"
[parent children]
(when-let [node (add-to-group! [parent (first children)])]
(doseq [child (rest children)]
@@ -151,26 +147,24 @@ based on the file at `path`
(add-tree-nodes parent child)))
(defn add!
"Adds the entities in `children` to the `group` entity of type [WidgetGroup](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/WidgetGroup.html)"
"Adds the entities in `children` to the `group` entity of type [WidgetGroup](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/WidgetGroup.html)."
[group & children]
(doseq [child children]
(add-to-group! [group child]))
group)
(defn ^:private create-group
"Internal use only"
[^WidgetGroup group children]
(apply add! (ActorEntity. group) children))
; check-box
(defn check-box*
"The function version of `check-box`"
[^String text arg]
(ActorEntity. (CheckBox. text arg)))
(defmacro check-box
"Returns an entity based on [CheckBox](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/CheckBox.html)
"Returns an entity based on [CheckBox](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/CheckBox.html).
(check-box \"I'm a check box\" (style :check-box off on font color))
(check-box \"I'm a check box\" (skin \"uiskin.json\"))"
@@ -180,19 +174,18 @@ based on the file at `path`
entity#))
(defmacro check-box!
"Calls a single method on a `check-box`"
"Calls a single method on a `check-box`."
[entity k & options]
`(u/call! ^Checkbox (u/get-obj ~entity :object) ~k ~@options))
; dialog
(defn dialog*
"The function version of `dialog`"
[text arg]
(ActorEntity. (Dialog. text arg)))
(defmacro dialog
"Returns an entity based on [Dialog](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Dialog.html)
"Returns an entity based on [Dialog](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Dialog.html).
(dialog \"I'm a dialog\" (style :window font font-color background))
(dialog \"I'm a dialog\" (skin \"uiskin.json\"))"
@@ -202,19 +195,18 @@ based on the file at `path`
entity#))
(defmacro dialog!
"Calls a single method on a `dialog`"
"Calls a single method on a `dialog`."
[entity k & options]
`(u/call! ^Dialog (u/get-obj ~entity :object) ~k ~@options))
; horizontal
(defn horizontal*
"The function version of `horizontal`"
[children]
(create-group (HorizontalGroup.) children))
(defmacro horizontal
"Returns an entity based on [HorizontalGroup](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/HorizontalGroup.html)
"Returns an entity based on [HorizontalGroup](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/HorizontalGroup.html).
(horizontal [entity-1 entity-2])"
[children & options]
@@ -223,14 +215,13 @@ based on the file at `path`
entity#))
(defmacro horizontal!
"Calls a single method on a `horizontal`"
"Calls a single method on a `horizontal`."
[entity k & options]
`(u/call! ^HorizontalGroup (u/get-obj ~entity :object) ~k ~@options))
; image
(defn image*
"The function version of `image`"
[arg]
(ActorEntity.
(cond
@@ -242,7 +233,7 @@ based on the file at `path`
(Image. arg))))
(defmacro image
"Returns an entity based on [Image](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Image.html)
"Returns an entity based on [Image](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Image.html).
(image \"image.png\")"
[arg & options]
@@ -251,19 +242,18 @@ based on the file at `path`
entity#))
(defmacro image!
"Calls a single method on a `image`"
"Calls a single method on a `image`."
[entity k & options]
`(u/call! ^Image (u/get-obj ~entity :object) ~k ~@options))
; image-button
(defn image-button*
"The function version of `image-button`"
[arg]
(ActorEntity. (ImageButton. arg)))
(defmacro image-button
"Returns an entity based on [ImageButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ImageButton.html)
"Returns an entity based on [ImageButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ImageButton.html).
(image-button (style :image-button up dn check img-up img-dn img-check))
(image-button (skin \"uiskin.json\"))"
@@ -273,19 +263,18 @@ based on the file at `path`
entity#))
(defmacro image-button!
"Calls a single method on a `image-button`"
"Calls a single method on a `image-button`."
[entity k & options]
`(u/call! ^ImageButton (u/get-obj ~entity :object) ~k ~@options))
; image-text-button
(defn image-text-button*
"The function version of `image-text-button`"
[^String text arg]
(ActorEntity. (ImageTextButton. text arg)))
(defmacro image-text-button
"Returns an entity based on [ImageTextButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ImageTextButton.html)
"Returns an entity based on [ImageTextButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ImageTextButton.html).
(image-text-button \"I'm an image text button\"
(style :image-text-button up down checked font))
@@ -296,14 +285,13 @@ based on the file at `path`
entity#))
(defmacro image-text-button!
"Calls a single method on a `image-text-button`"
"Calls a single method on a `image-text-button`."
[entity k & options]
`(u/call! ^ImageTextButton (u/get-obj ~entity :object) ~k ~@options))
; label
(defn label*
"The function version of `label`"
[^String text arg]
(ActorEntity.
(if (isa? (type arg) Color)
@@ -311,7 +299,7 @@ based on the file at `path`
(Label. text arg))))
(defmacro label
"Returns an entity based on [Label](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Label.html)
"Returns an entity based on [Label](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Label.html).
(label \"I'm a label\" (color :white))
(label \"I'm a label\" (style :label (g2d/bitmap-font) (color :white)))
@@ -322,19 +310,18 @@ based on the file at `path`
entity#))
(defmacro label!
"Calls a single method on a `label`"
"Calls a single method on a `label`."
[entity k & options]
`(u/call! ^Label (u/get-obj ~entity :object) ~k ~@options))
; scroll-pane
(defn scroll-pane*
"The function version of `scroll-pane`"
[child arg]
(ActorEntity. (ScrollPane. (u/get-obj child :object) arg)))
(defmacro scroll-pane
"Returns an entity based on [ScrollPane](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ScrollPane.html)
"Returns an entity based on [ScrollPane](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ScrollPane.html).
(scroll-pane table-entity (style :scroll-pane back h h-knob v v-knob))
(scroll-pane table-entity (skin \"uiskin.json\"))"
@@ -344,19 +331,18 @@ based on the file at `path`
entity#))
(defmacro scroll-pane!
"Calls a single method on a `scroll-pane`"
"Calls a single method on a `scroll-pane`."
[entity k & options]
`(u/call! ^ScrollPane (u/get-obj ~entity :object) ~k ~@options))
; select-box
(defn select-box*
"The function version of `select-box`"
[items arg]
(ActorEntity. (SelectBox. (into-array items) arg)))
(defmacro select-box
"Returns an entity based on [SelectBox](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/SelectBox.html)
"Returns an entity based on [SelectBox](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/SelectBox.html).
(select-box [\"Item 1\" \"Item 2\" \"Item 3\"]
(style :select-box font color back scroll-style list-style))
@@ -367,14 +353,13 @@ based on the file at `path`
entity#))
(defmacro select-box!
"Calls a single method on a `select-box`"
"Calls a single method on a `select-box`."
[entity k & options]
`(u/call! ^SelectBox (u/get-obj ~entity :object) ~k ~@options))
; slider
(defn slider*
"The function version of `slider`"
[{:keys [min max step vertical?]
:or {min 0 max 10 step 1 vertical? false}}
arg]
@@ -382,7 +367,7 @@ based on the file at `path`
(Slider. (float min) (float max) (float step) vertical? arg)))
(defmacro slider
"Returns an entity based on [Slider](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Slider.html)
"Returns an entity based on [Slider](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Slider.html).
(slider {:min 0 :max 10 :step 1 :vertical? false} (style :slider back knob))
(slider {:min 0 :max 10 :step 1 :vertical? false} (skin \"uiskin.json\"))"
@@ -392,19 +377,18 @@ based on the file at `path`
entity#))
(defmacro slider!
"Calls a single method on a `slider`"
"Calls a single method on a `slider`."
[entity k & options]
`(u/call! ^Slider (u/get-obj ~entity :object) ~k ~@options))
; stack
(defn stack*
"The function version of `stack`"
[children]
(create-group (Stack.) children))
(defmacro stack
"Returns an entity based on [Stack](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Stack.html)
"Returns an entity based on [Stack](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Stack.html).
(stack [entity-1 entity-2])"
[children & options]
@@ -413,19 +397,18 @@ based on the file at `path`
entity#))
(defmacro stack!
"Calls a single method on a `stack`"
"Calls a single method on a `stack`."
[entity k & options]
`(u/call! ^Stack (u/get-obj ~entity :object) ~k ~@options))
; table
(defn table*
"The function version of `table`"
[children]
(create-group (Table.) children))
(defmacro table
"Returns an entity based on [Table](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Table.html)
"Returns an entity based on [Table](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Table.html).
(table [entity-1 entity-2])"
[children & options]
@@ -434,19 +417,18 @@ based on the file at `path`
entity#))
(defmacro table!
"Calls a single method on a `table`"
"Calls a single method on a `table`."
[entity k & options]
`(u/call! ^Table (u/get-obj ~entity :object) ~k ~@options))
; text-button
(defn text-button*
"The function version of `text-button`"
[^String text arg]
(ActorEntity. (TextButton. text arg)))
(defmacro text-button
"Returns an entity based on [TextButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/TextButton.html)
"Returns an entity based on [TextButton](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/TextButton.html).
(text-button \"I'm a text button\" (style :text-button up dn checked font))
(text-button \"I'm a text button\" (skin \"uiskin.json\"))"
@@ -456,19 +438,18 @@ based on the file at `path`
entity#))
(defmacro text-button!
"Calls a single method on a `text-button`"
"Calls a single method on a `text-button`."
[entity k & options]
`(u/call! ^TextButton (u/get-obj ~entity :object) ~k ~@options))
; text-field
(defn text-field*
"The function version of `text-field`"
[^String text arg]
(ActorEntity. (TextField. text arg)))
(defmacro text-field
"Returns an entity based on [TextField](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/TextField.html)
"Returns an entity based on [TextField](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/TextField.html).
(text-field \"I'm a text field\" (style :text-field font col cur sel back))
(text-field \"I'm a text field\" (skin \"uiskin.json\"))"
@@ -478,19 +459,18 @@ based on the file at `path`
entity#))
(defmacro text-field!
"Calls a single method on a `text-field`"
"Calls a single method on a `text-field`."
[entity k & options]
`(u/call! ^TextField (u/get-obj ~entity :object) ~k ~@options))
; tree
(defn tree*
"The function version of `tree`"
[children arg]
(create-group (Tree. arg) children))
(defmacro tree
"Returns an entity based on [Tree](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Tree.html)
"Returns an entity based on [Tree](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Tree.html).
(tree [entity-1 entity-2] (style :tree plus minus selection))
(tree [entity-1 entity-2] (skin \"uiskin.json\"))"
@@ -500,19 +480,18 @@ based on the file at `path`
entity#))
(defmacro tree!
"Calls a single method on a `tree`"
"Calls a single method on a `tree`."
[entity k & options]
`(u/call! ^Tree (u/get-obj ~entity :object) ~k ~@options))
; vertical
(defn vertical*
"The function version of `vertical`"
[children]
(create-group (VerticalGroup.) children))
(defmacro vertical
"Returns an entity based on [VerticalGroup](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/VerticalGroup.html)
"Returns an entity based on [VerticalGroup](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/VerticalGroup.html).
(vertical [entity-1 entity-2])"
[children & options]
@@ -521,19 +500,18 @@ based on the file at `path`
entity#))
(defmacro vertical!
"Calls a single method on a `vertical`"
"Calls a single method on a `vertical`."
[entity k & options]
`(u/call! ^VerticalGroup (u/get-obj ~entity :object) ~k ~@options))
; window
(defn window*
"The function version of `window`"
[children ^String title arg]
(create-group (Window. title arg) children))
(defmacro window
"Returns an entity based on [Window](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Window.html)
"Returns an entity based on [Window](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Window.html).
(window [entity-1 entity-2] \"I'm a window\" (style :window title font col))
(window [entity-1 entity-2] \"I'm a window\" (skin \"uiskin.json\"))"
@@ -543,6 +521,6 @@ based on the file at `path`
entity#))
(defmacro window!
"Calls a single method on a `window`"
"Calls a single method on a `window`."
[entity k & options]
`(u/call! ^Window (u/get-obj ~entity :object) ~k ~@options))

View File

@@ -5,12 +5,10 @@
; misc
(defn throw-key-not-found
"Internal use only"
[k]
(throw (Exception. (str "The keyword " k " is not found."))))
(defn get-obj
"Internal use only"
[obj k]
(if (map? obj)
(or (get obj k)
@@ -22,31 +20,29 @@
(def ^:const main-package "com.badlogic.gdx")
(defn ^:private split-key
"Internal use only"
[k]
(-> k name (s/split #"-")))
(defn ^:private join-keys
"Internal use only"
[k-list]
(->> k-list (map name) (s/join ".")))
(defn key->upper
"Returns a string based on keyword `k` with upper case and underscores"
"Returns a string based on keyword `k` with upper case and underscores."
[k]
(->> (split-key k)
(map s/upper-case)
(s/join "_")))
(defn key->pascal
"Returns a string based on keyword `k` with pascal case and no delimiters"
"Returns a string based on keyword `k` with pascal case and no delimiters."
[k]
(->> (split-key k)
(map s/capitalize)
(s/join "")))
(defn key->camel
"Returns a string based on keyword `k` with camel case and no delimiters"
"Returns a string based on keyword `k` with camel case and no delimiters."
[k]
(let [parts (split-key k)]
(->> (rest parts)
@@ -55,44 +51,42 @@
(s/join ""))))
(defn key->method
"Returns a symbol based on keyword `k` formatted as a method call"
"Returns a symbol based on keyword `k` formatted as a method call."
[k]
(symbol (str "." (key->camel k))))
; classes/methods/fields
(defn ^:private add-divider
"Internal use only"
[args divider]
(let [[a1 a2] (take-last 2 args)]
(conj (vec (drop-last 2 args)) (str (name a1) divider (name a2)))))
(defn gdx
"Returns a fully-qualified LibGDX symbol"
"Returns a fully-qualified LibGDX symbol."
[& args]
(symbol (str main-package "." (join-keys args))))
(defn gdx-field
"Returns a fully-qualified LibGDX static method or field"
"Returns a fully-qualified LibGDX static method or field."
[& args]
(apply gdx (add-divider args "/")))
(defn gdx-class
"Returns a fully-qualified LibGDX static class"
"Returns a fully-qualified LibGDX static class."
[& args]
(apply gdx (add-divider args "$")))
; java interop
(defmacro call!
"Calls method `k` of `obj` with `args`
"Calls method `k` of `obj` with `args`.
(call! \"I'm a string\" :index-of \"s\")"
[obj k & args]
`(~(key->method k) ~obj ~@args))
(defn create-method-calls
"Internal use only"
[calls args]
(let [method-name (first args)
[my-args rest-args] (split-with #(not (keyword? %)) (rest args))]
@@ -102,14 +96,13 @@
calls)))
(defmacro calls!
"Calls methods on `obj`
"Calls methods on `obj`.
(calls! (java.util.ArrayList.) :add \"I'm a string\" :add \"So am I\")"
[obj & args]
`(doto ~obj ~@(create-method-calls [] args)))
(defn create-field-setters
"Internal use only"
[obj {:keys [] :as args}]
(map (fn [[k v]]
`(set! (. ~obj ~(symbol (key->camel k))) ~v))
@@ -118,7 +111,7 @@
(defmacro fields!
"Sets fields on `obj` (it is important that `obj` is a symbol, because when
the macro expands it will use it several times, and you probably don't want a
new object to be created each time a field is set)
new object to be created each time a field is set).
(fields! obj
:active true
@@ -132,24 +125,22 @@ new object to be created each time a field is set)
; data structures
(defn gdx-array*
"The function version of `gdx-array`"
[clj-arr]
(Array. true (into-array clj-arr) 1 (count clj-arr)))
(defmacro gdx-array
"Returns an [Array](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Array.html)
"Returns an [Array](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Array.html).
(gdx-array [1 2 3 4])"
[clj-arr & options]
`(calls! ^Array (gdx-array* ~clj-arr) ~@options))
(defmacro gdx-array!
"Calls a single method on a `gdx-array`"
"Calls a single method on a `gdx-array`."
[object k & options]
`(call! ^Array ~object ~k ~@options))
(defn gdx-array-map*
"The function version of `gdx-array-map`"
[clj-map]
(let [gdx-map (ArrayMap.)]
(doseq [[k v] clj-map]
@@ -157,13 +148,13 @@ new object to be created each time a field is set)
gdx-map))
(defmacro gdx-array-map
"Returns an [ArrayMap](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/ArrayMap.html)
"Returns an [ArrayMap](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/ArrayMap.html).
(gdx-array-map {:key-1 1 :key-2 2})"
[clj-map & options]
`(calls! ^ArrayMap (gdx-array-map* ~clj-map) ~@options))
(defmacro gdx-array-map!
"Calls a single method on a `gdx-array-map`"
"Calls a single method on a `gdx-array-map`."
[object k & options]
`(call! ^ArrayMap ~object ~k ~@options))