From fdf54411fea94e78031dccbc87b515c599e977e3 Mon Sep 17 00:00:00 2001 From: oakes Date: Sat, 25 Jan 2014 11:50:06 -0500 Subject: [PATCH] Fix macros and add texture-atlas --- src/play_clj/g2d.clj | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/play_clj/g2d.clj b/src/play_clj/g2d.clj index 71b7cb5..c1090db 100644 --- a/src/play_clj/g2d.clj +++ b/src/play_clj/g2d.clj @@ -2,7 +2,7 @@ (:require [play-clj.utils :as u]) (:import [com.badlogic.gdx.graphics Texture] [com.badlogic.gdx.graphics.g2d Animation BitmapFont NinePatch - ParticleEffect TextureRegion])) + ParticleEffect TextureAtlas TextureRegion])) (defmacro bitmap-font "Returns a [BitmapFont](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/BitmapFont.html) @@ -72,7 +72,7 @@ (nine-patch \"image.png\" :set-color (color :blue)) (nine-patch {:image \"image.png\" :left 10 :right 10 :top 10 :bottom 10})" [arg & options] - `(let [entity# (texture* ~arg)] + `(let [entity# (nine-patch* ~arg)] (u/calls! ^NinePatch (u/get-obj entity# :object) ~@options) entity#)) @@ -98,7 +98,7 @@ (files! :internal \"fire.p\") (files! :internal \"fire-images\"))" [& options] - `(let [entity# (texture*)] + `(let [entity# (particle-effect*)] (u/calls! ^ParticleEffect (u/get-obj entity# :object) ~@options) entity#)) @@ -109,6 +109,29 @@ [entity k & options] `(u/call! ^ParticleEffect (u/get-obj ~entity :object) ~k ~@options)) +; 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) + + (texture-atlas \"packed.txt\")" + [path & options] + `(let [^TextureAtlas object# (texture-atlas* path)] + (u/calls! object# ~@options) + object#)) + +(defmacro texture-atlas! + "Calls a single method on a `texture-atlas` + + (texture-atlas! object :create-patch \"test\")" + [object k & options] + `(u/call! ^TextureAtlas ~object ~k ~@options)) + ; animation (defmacro play-mode