Package com.badlogic.gdx.graphics.g2d
Class ParticleEffect
- java.lang.Object
-
- com.badlogic.gdx.graphics.g2d.ParticleEffect
-
- All Implemented Interfaces:
Disposable
- Direct Known Subclasses:
ParticleEffectPool.PooledEffect
public class ParticleEffect extends java.lang.Object implements Disposable
-
-
Field Summary
Fields Modifier and Type Field Description protected floatmotionScaleprotected floatxSizeScaleprotected floatySizeScale
-
Constructor Summary
Constructors Constructor Description ParticleEffect()ParticleEffect(ParticleEffect effect)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidallowCompletion()voiddispose()Disposes the texture for each sprite for each ParticleEmitter.voiddraw(Batch spriteBatch)voiddraw(Batch spriteBatch, float delta)ParticleEmitterfindEmitter(java.lang.String name)Returns the emitter with the specified name, or null.voidflipY()BoundingBoxgetBoundingBox()Returns the bounding box for all active particles.Array<ParticleEmitter>getEmitters()booleanisComplete()voidload(FileHandle effectFile, FileHandle imagesDir)voidload(FileHandle effectFile, TextureAtlas atlas)voidload(FileHandle effectFile, TextureAtlas atlas, java.lang.String atlasPrefix)voidloadEmitterImages(FileHandle imagesDir)voidloadEmitterImages(TextureAtlas atlas)voidloadEmitterImages(TextureAtlas atlas, java.lang.String atlasPrefix)voidloadEmitters(FileHandle effectFile)protected TextureloadTexture(FileHandle file)protected ParticleEmitternewEmitter(ParticleEmitter emitter)protected ParticleEmitternewEmitter(java.io.BufferedReader reader)voidpreAllocateParticles()Allocates all emitters particles.voidreset()Resets the effect so it can be started again like a new effect.voidreset(boolean resetScaling)Resets the effect so it can be started again like a new effect.voidsave(java.io.Writer output)voidscaleEffect(float scaleFactor)Permanently scales all the size and motion parameters of all the emitters in this effect.voidscaleEffect(float scaleFactor, float motionScaleFactor)Permanently scales all the size and motion parameters of all the emitters in this effect.voidscaleEffect(float xSizeScaleFactor, float ySizeScaleFactor, float motionScaleFactor)Permanently scales all the size and motion parameters of all the emitters in this effect.voidsetDuration(int duration)voidsetEmittersCleanUpBlendFunction(boolean cleanUpBlendFunction)Sets thecleansUpBlendFunctionparameter on allParticleEmitterscurrently in this ParticleEffect.voidsetFlip(boolean flipX, boolean flipY)voidsetPosition(float x, float y)voidstart()voidupdate(float delta)
-
-
-
Constructor Detail
-
ParticleEffect
public ParticleEffect()
-
ParticleEffect
public ParticleEffect(ParticleEffect effect)
-
-
Method Detail
-
start
public void start()
-
reset
public void reset()
Resets the effect so it can be started again like a new effect. Any changes to scale are reverted. Seereset(boolean).
-
reset
public void reset(boolean resetScaling)
Resets the effect so it can be started again like a new effect.- Parameters:
resetScaling- Whether to restore the original size and motion parameters if they were scaled. Repeated scaling and resetting may introduce error.
-
update
public void update(float delta)
-
draw
public void draw(Batch spriteBatch)
-
draw
public void draw(Batch spriteBatch, float delta)
-
allowCompletion
public void allowCompletion()
-
isComplete
public boolean isComplete()
-
setDuration
public void setDuration(int duration)
-
setPosition
public void setPosition(float x, float y)
-
setFlip
public void setFlip(boolean flipX, boolean flipY)
-
flipY
public void flipY()
-
getEmitters
public Array<ParticleEmitter> getEmitters()
-
findEmitter
public ParticleEmitter findEmitter(java.lang.String name)
Returns the emitter with the specified name, or null.
-
preAllocateParticles
public void preAllocateParticles()
Allocates all emitters particles. SeeParticleEmitter.preAllocateParticles()
-
save
public void save(java.io.Writer output) throws java.io.IOException- Throws:
java.io.IOException
-
load
public void load(FileHandle effectFile, FileHandle imagesDir)
-
load
public void load(FileHandle effectFile, TextureAtlas atlas)
-
load
public void load(FileHandle effectFile, TextureAtlas atlas, java.lang.String atlasPrefix)
-
loadEmitters
public void loadEmitters(FileHandle effectFile)
-
loadEmitterImages
public void loadEmitterImages(TextureAtlas atlas)
-
loadEmitterImages
public void loadEmitterImages(TextureAtlas atlas, java.lang.String atlasPrefix)
-
loadEmitterImages
public void loadEmitterImages(FileHandle imagesDir)
-
newEmitter
protected ParticleEmitter newEmitter(java.io.BufferedReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
newEmitter
protected ParticleEmitter newEmitter(ParticleEmitter emitter)
-
loadTexture
protected Texture loadTexture(FileHandle file)
-
dispose
public void dispose()
Disposes the texture for each sprite for each ParticleEmitter.- Specified by:
disposein interfaceDisposable
-
getBoundingBox
public BoundingBox getBoundingBox()
Returns the bounding box for all active particles. z axis will always be zero.
-
scaleEffect
public void scaleEffect(float scaleFactor)
Permanently scales all the size and motion parameters of all the emitters in this effect. If this effect originated from aParticleEffectPool, the scale will be reset when it is returned to the pool.
-
scaleEffect
public void scaleEffect(float scaleFactor, float motionScaleFactor)Permanently scales all the size and motion parameters of all the emitters in this effect. If this effect originated from aParticleEffectPool, the scale will be reset when it is returned to the pool.
-
scaleEffect
public void scaleEffect(float xSizeScaleFactor, float ySizeScaleFactor, float motionScaleFactor)Permanently scales all the size and motion parameters of all the emitters in this effect. If this effect originated from aParticleEffectPool, the scale will be reset when it is returned to the pool.
-
setEmittersCleanUpBlendFunction
public void setEmittersCleanUpBlendFunction(boolean cleanUpBlendFunction)
Sets thecleansUpBlendFunctionparameter on allParticleEmitterscurrently in this ParticleEffect.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:
cleanUpBlendFunction-
-
-