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, IRenderableA standard implementation for emitters that provide a particle effect.
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceEmitter.EmitterFinishedListenerField 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 voidactivate()voidaddParticle(Particle particle)Adds a particle to this Emitter's list of Particles.protected booleancanTakeNewParticles()Can take new particles.protected ParticlecreateNewParticle()Creates the new particle.EmitterDatadata()voiddeactivate()Deactivate.voiddelete()longgetAliveTime()Gets the alive time.java.awt.geom.Point2DgetOrigin()java.util.List<Particle>getParticles()Gets the particles.IRenderablegetRenderable(RenderType type)intgetTimeToLive()Gets the total time to live of this instance.booleanisActivated()booleanisActivateOnInit()booleanisFinished()Checks if the emitter duration is reached.booleanisPaused()Checks if is paused.booleanisStopped()voidonFinished(Emitter.EmitterFinishedListener listener)protected booleanparticleCanBeRemoved(Particle particle)Particle can be removed.voidremoveFinishedListener(Emitter.EmitterFinishedListener listener)voidrender(java.awt.Graphics2D g)Renders the visual contents of this instance onto the provided graphics context.voidsetEmitterData(EmitterData emitterData)voidsetEmitterData(java.lang.String emitterXmlPath)voidsetPaused(boolean paused)Sets the paused.voidsetStopped(boolean stopped)protected voidspawnParticle()Spawn particle.booleantimeToLiveReached()Time to live reached.voidtogglePaused()voidtoggleStopped()voidupdate()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:
getAliveTimein 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:IRenderableRenders the visual contents of this instance onto the provided graphics context.If an
Entityimplements 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:
renderin 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:
timeToLiveReachedin interfaceITimeToLive- Returns:
- true, if successful
togglePaused
public void togglePaused()toggleStopped
public void toggleStopped()update
public void update()Description copied from interface:IUpdateableThis 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:
updatein 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:ITimeToLiveGets the total time to live of this instance.- Specified by:
getTimeToLivein interfaceITimeToLive- Returns:
- The total time to live.
