Add particle-effect
This commit is contained in:
@@ -5,7 +5,8 @@
|
||||
[com.badlogic.gdx.audio Sound]
|
||||
[com.badlogic.gdx.graphics Camera Color GL20 OrthographicCamera
|
||||
PerspectiveCamera]
|
||||
[com.badlogic.gdx.graphics.g2d NinePatch SpriteBatch TextureRegion]
|
||||
[com.badlogic.gdx.graphics.g2d NinePatch ParticleEffect SpriteBatch
|
||||
TextureRegion]
|
||||
[com.badlogic.gdx.input GestureDetector
|
||||
GestureDetector$GestureListener]
|
||||
[com.badlogic.gdx.maps MapLayer MapLayers]
|
||||
|
||||
@@ -226,6 +226,14 @@ with the tiled map file at `path` and `unit` scale
|
||||
height (float (or height (.getTotalHeight object)))]
|
||||
(.draw object batch x y width height)))
|
||||
|
||||
(defmethod draw-entity! :particle-effect
|
||||
[^SpriteBatch batch {:keys [^ParticleEffect object x y]}]
|
||||
(assert object)
|
||||
(let [x (float (or x 0))
|
||||
y (float (or y 0))]
|
||||
(.setPosition object x y)
|
||||
(.draw object batch (graphics! :get-delta-time))))
|
||||
|
||||
(defmethod draw-entity! :actor
|
||||
[^SpriteBatch batch {:keys [^Actor object] :as entity}]
|
||||
(assert object)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
(:require [play-clj.utils :as u])
|
||||
(:import [com.badlogic.gdx.graphics Texture]
|
||||
[com.badlogic.gdx.graphics.g2d Animation BitmapFont NinePatch
|
||||
TextureRegion]))
|
||||
ParticleEffect TextureRegion]))
|
||||
|
||||
(defmacro bitmap-font
|
||||
"Returns a [BitmapFont](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/BitmapFont.html)
|
||||
@@ -12,6 +12,8 @@
|
||||
[& options]
|
||||
`(BitmapFont. ~@options))
|
||||
|
||||
; texture
|
||||
|
||||
(defn texture*
|
||||
"The function version of `texture`"
|
||||
[arg]
|
||||
@@ -45,6 +47,8 @@
|
||||
[entity k & options]
|
||||
`(u/call! ^TextureRegion (u/get-obj ~entity :object) ~k ~@options))
|
||||
|
||||
; nine-patch
|
||||
|
||||
(defn nine-patch*
|
||||
"The function version of `nine-patch`"
|
||||
[arg]
|
||||
@@ -80,6 +84,33 @@
|
||||
[entity k & options]
|
||||
`(u/call! ^NinePatch (u/get-obj ~entity :object) ~k ~@options))
|
||||
|
||||
; particle-effect
|
||||
|
||||
(defn particle-effect*
|
||||
"The function version of `particle-effect`"
|
||||
[]
|
||||
(u/create-entity (ParticleEffect.)))
|
||||
|
||||
(defmacro particle-effect
|
||||
"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\")
|
||||
(files! :internal \"fire-images\"))"
|
||||
[& options]
|
||||
`(let [entity# (texture*)]
|
||||
(u/calls! ^ParticleEffect (u/get-obj entity# :object) ~@options)
|
||||
entity#))
|
||||
|
||||
(defmacro particle-effect!
|
||||
"Calls a single method on a `particle-effect`
|
||||
|
||||
(particle-effect! entity :set-position 10 10)"
|
||||
[entity k & options]
|
||||
`(u/call! ^ParticleEffect (u/get-obj ~entity :object) ~k ~@options))
|
||||
|
||||
; animation
|
||||
|
||||
(defmacro play-mode
|
||||
"Returns a static field from [Animation](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/Animation.html)
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
(ns play-clj.utils
|
||||
(:require [clojure.string :as s])
|
||||
(:import [com.badlogic.gdx.graphics.g2d NinePatch TextureRegion]
|
||||
(:import [com.badlogic.gdx.graphics.g2d NinePatch ParticleEffect
|
||||
TextureRegion]
|
||||
[com.badlogic.gdx.scenes.scene2d Actor]
|
||||
[com.badlogic.gdx.utils Array ArrayMap]))
|
||||
|
||||
@@ -197,6 +198,10 @@ new object to be created each time a field is set)
|
||||
[obj]
|
||||
{:type :nine-patch :object obj})
|
||||
|
||||
(defmethod create-entity ParticleEffect
|
||||
[obj]
|
||||
{:type :particle-effect :object obj})
|
||||
|
||||
(defmethod create-entity Actor
|
||||
[obj]
|
||||
{:type :actor :object obj})
|
||||
|
||||
Reference in New Issue
Block a user