Package com.badlogic.gdx.graphics.g2d
Class ParticleEmitter
- java.lang.Object
-
- com.badlogic.gdx.graphics.g2d.ParticleEmitter
-
public class ParticleEmitter extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ParticleEmitter.GradientColorValue
static class
ParticleEmitter.IndependentScaledNumericValue
static class
ParticleEmitter.NumericValue
static class
ParticleEmitter.Particle
static class
ParticleEmitter.ParticleValue
static class
ParticleEmitter.RangedNumericValue
static class
ParticleEmitter.ScaledNumericValue
static class
ParticleEmitter.SpawnEllipseSide
static class
ParticleEmitter.SpawnShape
static class
ParticleEmitter.SpawnShapeValue
static class
ParticleEmitter.SpriteMode
-
Field Summary
Fields Modifier and Type Field Description float
duration
float
durationTimer
-
Constructor Summary
Constructors Constructor Description ParticleEmitter()
ParticleEmitter(ParticleEmitter emitter)
ParticleEmitter(java.io.BufferedReader reader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addParticle()
void
addParticles(int count)
void
allowCompletion()
Ignores thecontinuous
setting until the emitter is started again.boolean
cleansUpBlendFunction()
void
draw(Batch batch)
void
draw(Batch batch, float delta)
Updates and draws the particles.void
flipY()
int
getActiveCount()
ParticleEmitter.ScaledNumericValue
getAngle()
BoundingBox
getBoundingBox()
Returns the bounding box for all active particles.ParticleEmitter.RangedNumericValue
getDelay()
ParticleEmitter.RangedNumericValue
getDuration()
ParticleEmitter.ScaledNumericValue
getEmission()
ParticleEmitter.ScaledNumericValue
getGravity()
Array<java.lang.String>
getImagePaths()
ParticleEmitter.ScaledNumericValue
getLife()
ParticleEmitter.ScaledNumericValue
getLifeOffset()
int
getMaxParticleCount()
int
getMinParticleCount()
protected ParticleEmitter.RangedNumericValue[]
getMotionValues()
java.lang.String
getName()
protected ParticleEmitter.Particle[]
getParticles()
float
getPercentComplete()
ParticleEmitter.ScaledNumericValue
getRotation()
ParticleEmitter.ScaledNumericValue
getSpawnHeight()
ParticleEmitter.SpawnShapeValue
getSpawnShape()
ParticleEmitter.ScaledNumericValue
getSpawnWidth()
ParticleEmitter.SpriteMode
getSpriteMode()
Array<Sprite>
getSprites()
ParticleEmitter.GradientColorValue
getTint()
ParticleEmitter.ScaledNumericValue
getTransparency()
ParticleEmitter.ScaledNumericValue
getVelocity()
ParticleEmitter.ScaledNumericValue
getWind()
float
getX()
ParticleEmitter.RangedNumericValue
getXOffsetValue()
ParticleEmitter.ScaledNumericValue
getXScale()
protected ParticleEmitter.RangedNumericValue[]
getXSizeValues()
float
getY()
ParticleEmitter.RangedNumericValue
getYOffsetValue()
ParticleEmitter.ScaledNumericValue
getYScale()
protected ParticleEmitter.RangedNumericValue[]
getYSizeValues()
boolean
isAdditive()
boolean
isAligned()
boolean
isAttached()
boolean
isBehind()
boolean
isComplete()
boolean
isContinuous()
boolean
isPremultipliedAlpha()
void
load(java.io.BufferedReader reader)
void
matchMotion(ParticleEmitter template)
Sets all motion-related ranged values to match those of the template emitter.void
matchSize(ParticleEmitter template)
Sets all size-related ranged values to match those of the template emitter.void
matchXSize(ParticleEmitter template)
Sets all horizontal size-related ranged values to match those of the template emitter.void
matchYSize(ParticleEmitter template)
Sets all vertical size-related ranged values to match those of the template emitter.protected ParticleEmitter.Particle
newParticle(Sprite sprite)
void
preAllocateParticles()
Allocates max particles emitter can hold.void
reset()
void
save(java.io.Writer output)
void
scaleMotion(float scale)
Permanently scales the speed of the emitter by scaling all its ranged values related to motion.void
scaleSize(float scale)
Permanently scales the size of the emitter by scaling all its ranged values related to size.void
scaleSize(float scaleX, float scaleY)
Permanently scales the size of the emitter by scaling all its ranged values related to size.void
setAdditive(boolean additive)
void
setAligned(boolean aligned)
void
setAttached(boolean attached)
void
setBehind(boolean behind)
void
setCleansUpBlendFunction(boolean cleansUpBlendFunction)
Set whether to automatically return theBatch
's blend function to the alpha-blending default (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) when done drawing.void
setContinuous(boolean continuous)
void
setFlip(boolean flipX, boolean flipY)
void
setImagePaths(Array<java.lang.String> imagePaths)
void
setMaxParticleCount(int maxParticleCount)
void
setMinParticleCount(int minParticleCount)
void
setName(java.lang.String name)
void
setPosition(float x, float y)
void
setPremultipliedAlpha(boolean premultipliedAlpha)
void
setSpriteMode(ParticleEmitter.SpriteMode spriteMode)
void
setSprites(Array<Sprite> sprites)
void
start()
void
update(float delta)
-
-
-
Constructor Detail
-
ParticleEmitter
public ParticleEmitter()
-
ParticleEmitter
public ParticleEmitter(java.io.BufferedReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
ParticleEmitter
public ParticleEmitter(ParticleEmitter emitter)
-
-
Method Detail
-
setMaxParticleCount
public void setMaxParticleCount(int maxParticleCount)
-
addParticle
public void addParticle()
-
addParticles
public void addParticles(int count)
-
update
public void update(float delta)
-
draw
public void draw(Batch batch)
-
draw
public void draw(Batch batch, float delta)
Updates and draws the particles. This is slightly more efficient than callingupdate(float)
anddraw(Batch)
separately.
-
start
public void start()
-
reset
public void reset()
-
newParticle
protected ParticleEmitter.Particle newParticle(Sprite sprite)
-
getParticles
protected ParticleEmitter.Particle[] getParticles()
-
setPosition
public void setPosition(float x, float y)
-
setSpriteMode
public void setSpriteMode(ParticleEmitter.SpriteMode spriteMode)
-
preAllocateParticles
public void preAllocateParticles()
Allocates max particles emitter can hold. Usually called early on to avoid allocation on updates.setSprites(Array)
must have been set before calling this method
-
allowCompletion
public void allowCompletion()
Ignores thecontinuous
setting until the emitter is started again. This allows the emitter to stop smoothly.
-
getSpriteMode
public ParticleEmitter.SpriteMode getSpriteMode()
-
getName
public java.lang.String getName()
-
setName
public void setName(java.lang.String name)
-
getLife
public ParticleEmitter.ScaledNumericValue getLife()
-
getXScale
public ParticleEmitter.ScaledNumericValue getXScale()
-
getYScale
public ParticleEmitter.ScaledNumericValue getYScale()
-
getRotation
public ParticleEmitter.ScaledNumericValue getRotation()
-
getTint
public ParticleEmitter.GradientColorValue getTint()
-
getVelocity
public ParticleEmitter.ScaledNumericValue getVelocity()
-
getWind
public ParticleEmitter.ScaledNumericValue getWind()
-
getGravity
public ParticleEmitter.ScaledNumericValue getGravity()
-
getAngle
public ParticleEmitter.ScaledNumericValue getAngle()
-
getEmission
public ParticleEmitter.ScaledNumericValue getEmission()
-
getTransparency
public ParticleEmitter.ScaledNumericValue getTransparency()
-
getDuration
public ParticleEmitter.RangedNumericValue getDuration()
-
getDelay
public ParticleEmitter.RangedNumericValue getDelay()
-
getLifeOffset
public ParticleEmitter.ScaledNumericValue getLifeOffset()
-
getXOffsetValue
public ParticleEmitter.RangedNumericValue getXOffsetValue()
-
getYOffsetValue
public ParticleEmitter.RangedNumericValue getYOffsetValue()
-
getSpawnWidth
public ParticleEmitter.ScaledNumericValue getSpawnWidth()
-
getSpawnHeight
public ParticleEmitter.ScaledNumericValue getSpawnHeight()
-
getSpawnShape
public ParticleEmitter.SpawnShapeValue getSpawnShape()
-
isAttached
public boolean isAttached()
-
setAttached
public void setAttached(boolean attached)
-
isContinuous
public boolean isContinuous()
-
setContinuous
public void setContinuous(boolean continuous)
-
isAligned
public boolean isAligned()
-
setAligned
public void setAligned(boolean aligned)
-
isAdditive
public boolean isAdditive()
-
setAdditive
public void setAdditive(boolean additive)
-
cleansUpBlendFunction
public boolean cleansUpBlendFunction()
- Returns:
- Whether this ParticleEmitter automatically returns the
Batch
's blend function to the alpha-blending default (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) when done drawing.
-
setCleansUpBlendFunction
public void setCleansUpBlendFunction(boolean cleansUpBlendFunction)
Set whether to automatically return theBatch
's blend function to the alpha-blending default (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) when done drawing. Is true by default. If set to false, the Batch's blend function is left as it was for drawing this ParticleEmitter, which prevents the Batch from being flushed repeatedly if consecutive ParticleEmitters with the same additive or pre-multiplied alpha state are drawn in a row.IMPORTANT: If set to false and if the next object to use this Batch expects alpha blending, you are responsible for setting the Batch's blend function to (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) before that next object is drawn.
- Parameters:
cleansUpBlendFunction
-
-
isBehind
public boolean isBehind()
-
setBehind
public void setBehind(boolean behind)
-
isPremultipliedAlpha
public boolean isPremultipliedAlpha()
-
setPremultipliedAlpha
public void setPremultipliedAlpha(boolean premultipliedAlpha)
-
getMinParticleCount
public int getMinParticleCount()
-
setMinParticleCount
public void setMinParticleCount(int minParticleCount)
-
getMaxParticleCount
public int getMaxParticleCount()
-
isComplete
public boolean isComplete()
-
getPercentComplete
public float getPercentComplete()
-
getX
public float getX()
-
getY
public float getY()
-
getActiveCount
public int getActiveCount()
-
getImagePaths
public Array<java.lang.String> getImagePaths()
-
setImagePaths
public void setImagePaths(Array<java.lang.String> imagePaths)
-
setFlip
public void setFlip(boolean flipX, boolean flipY)
-
flipY
public void flipY()
-
getBoundingBox
public BoundingBox getBoundingBox()
Returns the bounding box for all active particles. z axis will always be zero.
-
getXSizeValues
protected ParticleEmitter.RangedNumericValue[] getXSizeValues()
-
getYSizeValues
protected ParticleEmitter.RangedNumericValue[] getYSizeValues()
-
getMotionValues
protected ParticleEmitter.RangedNumericValue[] getMotionValues()
-
scaleSize
public void scaleSize(float scale)
Permanently scales the size of the emitter by scaling all its ranged values related to size.
-
scaleSize
public void scaleSize(float scaleX, float scaleY)
Permanently scales the size of the emitter by scaling all its ranged values related to size.
-
scaleMotion
public void scaleMotion(float scale)
Permanently scales the speed of the emitter by scaling all its ranged values related to motion.
-
matchSize
public void matchSize(ParticleEmitter template)
Sets all size-related ranged values to match those of the template emitter.
-
matchXSize
public void matchXSize(ParticleEmitter template)
Sets all horizontal size-related ranged values to match those of the template emitter.
-
matchYSize
public void matchYSize(ParticleEmitter template)
Sets all vertical size-related ranged values to match those of the template emitter.
-
matchMotion
public void matchMotion(ParticleEmitter template)
Sets all motion-related ranged values to match those of the template emitter.
-
save
public void save(java.io.Writer output) throws java.io.IOException
- Throws:
java.io.IOException
-
load
public void load(java.io.BufferedReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
-