Rename entity class and provide default delta-time
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
(:import [com.badlogic.gdx.graphics Texture]
|
||||
[com.badlogic.gdx.graphics.g2d Animation BitmapFont NinePatch
|
||||
ParticleEffect TextureAtlas TextureRegion]
|
||||
[play_clj.utils TextureEntity NinePatchEntity ParticleEntity]))
|
||||
[play_clj.utils TextureEntity NinePatchEntity ParticleEffectEntity]))
|
||||
|
||||
(defmacro bitmap-font
|
||||
"Returns a [BitmapFont](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/BitmapFont.html)
|
||||
@@ -90,7 +90,7 @@
|
||||
(defn particle-effect*
|
||||
"The function version of `particle-effect`"
|
||||
[]
|
||||
(ParticleEntity. (ParticleEffect.)))
|
||||
(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)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
(ns play-clj.utils
|
||||
(:require [clojure.string :as s])
|
||||
(:import [com.badlogic.gdx.graphics.g2d NinePatch ParticleEffect SpriteBatch
|
||||
(:import [com.badlogic.gdx Gdx Graphics]
|
||||
[com.badlogic.gdx.graphics.g2d NinePatch ParticleEffect SpriteBatch
|
||||
TextureRegion]
|
||||
[com.badlogic.gdx.graphics.g3d Environment ModelBatch ModelInstance]
|
||||
[com.badlogic.gdx.scenes.scene2d Actor]
|
||||
@@ -194,11 +195,12 @@ new object to be created each time a field is set)
|
||||
height (float (or height (.getTotalHeight object)))]
|
||||
(.draw object ^SpriteBatch batch x y width height))))
|
||||
|
||||
(defrecord ParticleEntity [object] Entity
|
||||
(defrecord ParticleEffectEntity [object] Entity
|
||||
(draw-entity! [{:keys [^ParticleEffect object x y delta-time]} batch]
|
||||
(let [x (float (or x 0))
|
||||
y (float (or y 0))
|
||||
delta-time (float delta-time)]
|
||||
^Graphics g (Gdx/graphics)
|
||||
delta-time (float (or delta-time (.getDeltaTime g)))]
|
||||
(.setPosition object x y)
|
||||
(.draw object ^SpriteBatch batch delta-time))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user