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 float
motionScale
protected float
xSizeScale
protected float
ySizeScale
-
Constructor Summary
Constructors Constructor Description ParticleEffect()
ParticleEffect(ParticleEffect effect)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
allowCompletion()
void
dispose()
Disposes the texture for each sprite for each ParticleEmitter.void
draw(Batch spriteBatch)
void
draw(Batch spriteBatch, float delta)
ParticleEmitter
findEmitter(java.lang.String name)
Returns the emitter with the specified name, or null.void
flipY()
BoundingBox
getBoundingBox()
Returns the bounding box for all active particles.Array<ParticleEmitter>
getEmitters()
boolean
isComplete()
void
load(FileHandle effectFile, FileHandle imagesDir)
void
load(FileHandle effectFile, TextureAtlas atlas)
void
load(FileHandle effectFile, TextureAtlas atlas, java.lang.String atlasPrefix)
void
loadEmitterImages(FileHandle imagesDir)
void
loadEmitterImages(TextureAtlas atlas)
void
loadEmitterImages(TextureAtlas atlas, java.lang.String atlasPrefix)
void
loadEmitters(FileHandle effectFile)
protected Texture
loadTexture(FileHandle file)
protected ParticleEmitter
newEmitter(ParticleEmitter emitter)
protected ParticleEmitter
newEmitter(java.io.BufferedReader reader)
void
preAllocateParticles()
Allocates all emitters particles.void
reset()
Resets the effect so it can be started again like a new effect.void
reset(boolean resetScaling)
Resets the effect so it can be started again like a new effect.void
save(java.io.Writer output)
void
scaleEffect(float scaleFactor)
Permanently scales all the size and motion parameters of all the emitters in this effect.void
scaleEffect(float scaleFactor, float motionScaleFactor)
Permanently scales all the size and motion parameters of all the emitters in this effect.void
scaleEffect(float xSizeScaleFactor, float ySizeScaleFactor, float motionScaleFactor)
Permanently scales all the size and motion parameters of all the emitters in this effect.void
setDuration(int duration)
void
setEmittersCleanUpBlendFunction(boolean cleanUpBlendFunction)
Sets thecleansUpBlendFunction
parameter on allParticleEmitters
currently in this ParticleEffect.void
setFlip(boolean flipX, boolean flipY)
void
setPosition(float x, float y)
void
start()
void
update(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:
dispose
in 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 thecleansUpBlendFunction
parameter on allParticleEmitters
currently 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
-
-
-