From 25895faa9b2c0cc7ccc865ece6ab3c8b24c6de47 Mon Sep 17 00:00:00 2001 From: oakes Date: Sat, 5 Apr 2014 23:50:42 -0400 Subject: [PATCH] Add boolean entity functions --- src/play_clj/core_graphics.clj | 5 +++++ src/play_clj/g2d.clj | 15 +++++++++++++++ src/play_clj/g3d.clj | 5 +++++ src/play_clj/ui.clj | 5 +++++ 4 files changed, 30 insertions(+) diff --git a/src/play_clj/core_graphics.clj b/src/play_clj/core_graphics.clj index b010b5a..07d88ab 100644 --- a/src/play_clj/core_graphics.clj +++ b/src/play_clj/core_graphics.clj @@ -55,6 +55,11 @@ `(let [^ShapeRenderer object# (u/get-obj ~entity :object)] (u/call! object# ~k ~@options))) +(defn shape? + "Returns true if `entity` is a `shape`." + [entity] + (isa? (type entity) ShapeEntity)) + ; tiled maps (defn tiled-map* diff --git a/src/play_clj/g2d.clj b/src/play_clj/g2d.clj index 0af9bf0..f5b498b 100644 --- a/src/play_clj/g2d.clj +++ b/src/play_clj/g2d.clj @@ -48,6 +48,11 @@ [entity k & options] `(u/call! ^TextureRegion (u/get-obj ~entity :object) ~k ~@options)) +(defn texture? + "Returns true if `entity` is a `texture`." + [entity] + (isa? (type entity) TextureEntity)) + ; nine-patch (defn nine-patch* @@ -84,6 +89,11 @@ [entity k & options] `(u/call! ^NinePatch (u/get-obj ~entity :object) ~k ~@options)) +(defn nine-patch? + "Returns true if `entity` is a `nine-patch`." + [entity] + (isa? (type entity) NinePatchEntity)) + ; particle-effect (defn particle-effect* @@ -108,6 +118,11 @@ [entity k & options] `(u/call! ^ParticleEffect (u/get-obj ~entity :object) ~k ~@options)) +(defn particle-effect? + "Returns true if `entity` is a `particle-effect`." + [entity] + (isa? (type entity) ParticleEffectEntity)) + ; texture-atlas (defn texture-atlas* diff --git a/src/play_clj/g3d.clj b/src/play_clj/g3d.clj index 30b9857..cc0a2ef 100644 --- a/src/play_clj/g3d.clj +++ b/src/play_clj/g3d.clj @@ -91,6 +91,11 @@ `(let [^ModelInstance object# (u/get-obj ~entity :object)] (u/call! object# ~k ~@options))) +(defn model? + "Returns true if `entity` is a `model`." + [entity] + (isa? (type entity) ModelEntity)) + ; model-builder (defn model-builder* diff --git a/src/play_clj/ui.clj b/src/play_clj/ui.clj index 6ba44ef..9765e0e 100644 --- a/src/play_clj/ui.clj +++ b/src/play_clj/ui.clj @@ -14,6 +14,11 @@ [com.esotericsoftware.tablelayout Cell] [play_clj.entities ActorEntity])) +(defn actor? + "Returns true if `entity` is one of the UI entities." + [entity] + (isa? (type entity) ActorEntity)) + (defmacro drawable "Returns a subclass of [BaseDrawable](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/BaseDrawable.html).