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 classParticleEmitter.GradientColorValuestatic classParticleEmitter.IndependentScaledNumericValuestatic classParticleEmitter.NumericValuestatic classParticleEmitter.Particlestatic classParticleEmitter.ParticleValuestatic classParticleEmitter.RangedNumericValuestatic classParticleEmitter.ScaledNumericValuestatic classParticleEmitter.SpawnEllipseSidestatic classParticleEmitter.SpawnShapestatic classParticleEmitter.SpawnShapeValuestatic classParticleEmitter.SpriteMode
-
Field Summary
Fields Modifier and Type Field Description floatdurationfloatdurationTimer
-
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 voidaddParticle()voidaddParticles(int count)voidallowCompletion()Ignores thecontinuoussetting until the emitter is started again.booleancleansUpBlendFunction()voiddraw(Batch batch)voiddraw(Batch batch, float delta)Updates and draws the particles.voidflipY()intgetActiveCount()ParticleEmitter.ScaledNumericValuegetAngle()BoundingBoxgetBoundingBox()Returns the bounding box for all active particles.ParticleEmitter.RangedNumericValuegetDelay()ParticleEmitter.RangedNumericValuegetDuration()ParticleEmitter.ScaledNumericValuegetEmission()ParticleEmitter.ScaledNumericValuegetGravity()Array<java.lang.String>getImagePaths()ParticleEmitter.ScaledNumericValuegetLife()ParticleEmitter.ScaledNumericValuegetLifeOffset()intgetMaxParticleCount()intgetMinParticleCount()protected ParticleEmitter.RangedNumericValue[]getMotionValues()java.lang.StringgetName()protected ParticleEmitter.Particle[]getParticles()floatgetPercentComplete()ParticleEmitter.ScaledNumericValuegetRotation()ParticleEmitter.ScaledNumericValuegetSpawnHeight()ParticleEmitter.SpawnShapeValuegetSpawnShape()ParticleEmitter.ScaledNumericValuegetSpawnWidth()ParticleEmitter.SpriteModegetSpriteMode()Array<Sprite>getSprites()ParticleEmitter.GradientColorValuegetTint()ParticleEmitter.ScaledNumericValuegetTransparency()ParticleEmitter.ScaledNumericValuegetVelocity()ParticleEmitter.ScaledNumericValuegetWind()floatgetX()ParticleEmitter.RangedNumericValuegetXOffsetValue()ParticleEmitter.ScaledNumericValuegetXScale()protected ParticleEmitter.RangedNumericValue[]getXSizeValues()floatgetY()ParticleEmitter.RangedNumericValuegetYOffsetValue()ParticleEmitter.ScaledNumericValuegetYScale()protected ParticleEmitter.RangedNumericValue[]getYSizeValues()booleanisAdditive()booleanisAligned()booleanisAttached()booleanisBehind()booleanisComplete()booleanisContinuous()booleanisPremultipliedAlpha()voidload(java.io.BufferedReader reader)voidmatchMotion(ParticleEmitter template)Sets all motion-related ranged values to match those of the template emitter.voidmatchSize(ParticleEmitter template)Sets all size-related ranged values to match those of the template emitter.voidmatchXSize(ParticleEmitter template)Sets all horizontal size-related ranged values to match those of the template emitter.voidmatchYSize(ParticleEmitter template)Sets all vertical size-related ranged values to match those of the template emitter.protected ParticleEmitter.ParticlenewParticle(Sprite sprite)voidpreAllocateParticles()Allocates max particles emitter can hold.voidreset()voidsave(java.io.Writer output)voidscaleMotion(float scale)Permanently scales the speed of the emitter by scaling all its ranged values related to motion.voidscaleSize(float scale)Permanently scales the size of the emitter by scaling all its ranged values related to size.voidscaleSize(float scaleX, float scaleY)Permanently scales the size of the emitter by scaling all its ranged values related to size.voidsetAdditive(boolean additive)voidsetAligned(boolean aligned)voidsetAttached(boolean attached)voidsetBehind(boolean behind)voidsetCleansUpBlendFunction(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.voidsetContinuous(boolean continuous)voidsetFlip(boolean flipX, boolean flipY)voidsetImagePaths(Array<java.lang.String> imagePaths)voidsetMaxParticleCount(int maxParticleCount)voidsetMinParticleCount(int minParticleCount)voidsetName(java.lang.String name)voidsetPosition(float x, float y)voidsetPremultipliedAlpha(boolean premultipliedAlpha)voidsetSpriteMode(ParticleEmitter.SpriteMode spriteMode)voidsetSprites(Array<Sprite> sprites)voidstart()voidupdate(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 thecontinuoussetting 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
-
-