Class Emitter
java.lang.Object
de.gurkenlabs.litiengine.entities.Entity
de.gurkenlabs.litiengine.graphics.emitters.Emitter
- All Implemented Interfaces:
EntityRenderedListener
,EntityRenderListener
,IEntity
,IRenderable
,ITimeToLive
,IUpdateable
,Tweenable
,java.util.EventListener
- Direct Known Subclasses:
EntityEmitter
public class Emitter
extends Entity
implements IUpdateable, ITimeToLive, IRenderable
A standard implementation for emitters that provide a particle effect.
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Emitter.EmitterFinishedListener
Field Summary
Constructor Summary
Constructors Constructor Description Emitter()
Emitter(double originX, double originY)
Emitter(double x, double y, EmitterData emitterData)
Emitter(double x, double y, java.lang.String emitterXml)
Emitter(EmitterData emitterData)
Emitter(java.awt.geom.Point2D origin)
Emitter(java.awt.geom.Point2D origin, EmitterData emitterData)
Emitter(java.awt.geom.Point2D origin, java.lang.String emitterXml)
Method Summary
Modifier and Type Method Description void
activate()
void
addParticle(Particle particle)
Adds a particle to this Emitter's list of Particles.protected boolean
canTakeNewParticles()
Can take new particles.protected Particle
createNewParticle()
Creates the new particle.EmitterData
data()
void
deactivate()
Deactivate.void
delete()
long
getAliveTime()
Gets the alive time.java.awt.geom.Point2D
getOrigin()
java.util.List<Particle>
getParticles()
Gets the particles.IRenderable
getRenderable(RenderType type)
int
getTimeToLive()
Gets the total time to live of this instance.boolean
isActivated()
boolean
isActivateOnInit()
boolean
isFinished()
Checks if the emitter duration is reached.boolean
isPaused()
Checks if is paused.boolean
isStopped()
void
onFinished(Emitter.EmitterFinishedListener listener)
protected boolean
particleCanBeRemoved(Particle particle)
Particle can be removed.void
removeFinishedListener(Emitter.EmitterFinishedListener listener)
void
render(java.awt.Graphics2D g)
Renders the visual contents of this instance onto the provided graphics context.void
setEmitterData(EmitterData emitterData)
void
setEmitterData(java.lang.String emitterXmlPath)
void
setPaused(boolean paused)
Sets the paused.void
setStopped(boolean stopped)
protected void
spawnParticle()
Spawn particle.boolean
timeToLiveReached()
Time to live reached.void
togglePaused()
void
toggleStopped()
void
update()
This method is called by the game loop on all objects that are attached to the loop.Methods inherited from class de.gurkenlabs.litiengine.entities.Entity
actions, addController, addEntityRenderListener, addListener, addTag, addTransformListener, animations, attachControllers, behavior, canRender, detachControllers, getAngle, getBoundingBox, getCenter, getController, getControllers, getEnvironment, getHeight, getLocation, getMapId, getName, getProperties, getRenderType, getTags, getTweenValues, getWidth, getX, getY, hasTag, isLoaded, isVisible, loaded, onMessage, onMessage, onRendered, perform, register, removed, removeListener, removeListener, removeListener, removeListener, removeListener, removeTag, rendered, rendering, renderWithLayer, sendMessage, setAngle, setController, setHeight, setLocation, setLocation, setMapId, setName, setRenderType, setRenderWithLayer, setSize, setTweenValues, setVisible, setWidth, setX, setY, toString
Constructor Details
Emitter
public Emitter()Emitter
Emitter
Emitter
Emitter
public Emitter(double x, double y, java.lang.String emitterXml)Emitter
public Emitter(java.awt.geom.Point2D origin, java.lang.String emitterXml)Emitter
public Emitter(double originX, double originY)Emitter
public Emitter(java.awt.geom.Point2D origin)
Method Details
activate
public void activate()addParticle
Adds a particle to this Emitter's list of Particles.- Parameters:
particle
- the particle
deactivate
public void deactivate()Deactivate.delete
public void delete()getAliveTime
public long getAliveTime()Gets the alive time.- Specified by:
getAliveTime
in interfaceITimeToLive
- Returns:
- the alive time
data
getOrigin
public java.awt.geom.Point2D getOrigin()getRenderable
getParticles
Gets the particles.- Returns:
- the particles
isActivateOnInit
public boolean isActivateOnInit()isActivated
public boolean isActivated()isFinished
public boolean isFinished()Checks if the emitter duration is reached.- Returns:
- true, if the emitter is finished
isPaused
public boolean isPaused()Checks if is paused.- Returns:
- true, if is paused
isStopped
public boolean isStopped()onFinished
removeFinishedListener
render
public void render(java.awt.Graphics2D g)Description copied from interface:IRenderable
Renders the visual contents of this instance onto the provided graphics context.If an
Entity
implements this interface, this method will be called right after the entity was rendered from the environment. Allowing for a custom rendering mechanism.This interface can be implemented in general by anything that should be rendered to the game's screen.
- Specified by:
render
in interfaceIRenderable
- Parameters:
g
- The current graphics object onto which this instance will render its visual contents.- See Also:
RenderEngine.renderEntity(Graphics2D, de.gurkenlabs.litiengine.entities.IEntity)
setPaused
public void setPaused(boolean paused)Sets the paused.- Parameters:
paused
- the new paused
setStopped
public void setStopped(boolean stopped)setEmitterData
setEmitterData
public void setEmitterData(java.lang.String emitterXmlPath)timeToLiveReached
public boolean timeToLiveReached()Time to live reached.- Specified by:
timeToLiveReached
in interfaceITimeToLive
- Returns:
- true, if successful
togglePaused
public void togglePaused()toggleStopped
public void toggleStopped()update
public void update()Description copied from interface:IUpdateable
This method is called by the game loop on all objects that are attached to the loop. It's called on every tick of the loop and the frequency can be configured using theClientConfiguration
.- Specified by:
update
in interfaceIUpdateable
- See Also:
ClientConfiguration.setMaxFps(int)
canTakeNewParticles
protected boolean canTakeNewParticles()Can take new particles.- Returns:
- Whether-or-not the effect can hold any more particles.
createNewParticle
Creates the new particle.- Returns:
- the particle
particleCanBeRemoved
Particle can be removed.- Parameters:
particle
- the particle- Returns:
- true, if successful
spawnParticle
protected void spawnParticle()Spawn particle.getTimeToLive
public int getTimeToLive()Description copied from interface:ITimeToLive
Gets the total time to live of this instance.- Specified by:
getTimeToLive
in interfaceITimeToLive
- Returns:
- The total time to live.