Class Particle
java.lang.Object
de.gurkenlabs.litiengine.graphics.emitters.particles.Particle
- All Implemented Interfaces:
ITimeToLive
- Direct Known Subclasses:
ShapeParticle,SpriteParticle,TextParticle
public abstract class Particle
extends java.lang.Object
implements ITimeToLiveConstructor Summary
Constructors Constructor Description Particle(float width, float height)Constructs a new particle.Method Summary
Modifier and Type Method Description java.awt.geom.Point2DgetAbsoluteLocation(java.awt.geom.Point2D effectLocation)protected floatgetAbsoluteX(java.awt.geom.Point2D emitterOrigin)protected floatgetAbsoluteY(java.awt.geom.Point2D emitterOrigin)floatgetAccelerationX()floatgetAccelerationY()longgetAliveTime()Gets the time this instance is alive.floatgetAngle()java.awt.geom.Rectangle2DgetBoundingBox(java.awt.geom.Point2D origin)Gets the current bounding box of the particle, depending on its spawn location.CollisiongetCollisionType()java.awt.ColorgetColor()RenderTypegetCustomRenderType()floatgetDeltaAngle()floatgetDeltaHeight()floatgetDeltaWidth()floatgetHeight()floatgetOpacity()java.awt.geom.Point2DgetRenderLocation(java.awt.geom.Point2D effectLocation)Gets the location relative to the specified effect location.intgetTimeToLive()Gets the total time to live of this instance.floatgetVelocityX()floatgetVelocityY()floatgetWidth()floatgetX()floatgetY()Particleinit(EmitterData data)booleanisAntiAliased()booleanisContinuousCollisionEnabled()booleanisFading()booleanisFadingOnCollision()booleanisOutlineOnly()booleanisStoppingOnCollision()abstract voidrender(java.awt.Graphics2D g, java.awt.geom.Point2D emitterOrigin)ParticlesetAccelerationX(float accelerationX)ParticlesetAccelerationY(float accelerationY)ParticlesetAngle(float angle)ParticlesetAntiAliasing(boolean antiAliasing)ParticlesetCollisionType(Collision collisionType)ParticlesetColor(java.awt.Color color)ParticlesetContinuousCollision(boolean ccd)Enabling this check can be very performance hungry and should be used with caution and only for a small amount of particles.ParticlesetCustomRenderType(RenderType renderType)ParticlesetDeltaAngle(float deltaAngle)ParticlesetDeltaHeight(float deltaHeight)ParticlesetDeltaWidth(float deltaWidth)ParticlesetFade(boolean fade)ParticlesetFadeOnCollision(boolean fadeOnCollision)ParticlesetHeight(float height)ParticlesetOutlineOnly(boolean outlineOnly)voidsetStopOnCollision(boolean stopOnCollision)ParticlesetTimeToLive(int ttl)ParticlesetVelocityX(float velocityX)ParticlesetVelocityY(float velocityY)ParticlesetWidth(float width)ParticlesetX(float x)ParticlesetY(float y)booleantimeToLiveReached()Determines whether this instance has exceeded its time to live.voidupdate(java.awt.geom.Point2D emitterOrigin, float updateRatio)Updates the effect's position, change in xCurrent, change in yCurrent, remaining lifetime, and color.booleanusesCustomRenderType()
Constructor Details
Particle
public Particle(float width, float height)Constructs a new particle.- Parameters:
width- the particle width in pixelsheight- the particle height in pixels
Method Details
getAliveTime
public long getAliveTime()Description copied from interface:ITimeToLiveGets the time this instance is alive.- Specified by:
getAliveTimein interfaceITimeToLive- Returns:
- Returns how long this instance is alive.
getBoundingBox
public java.awt.geom.Rectangle2D getBoundingBox(java.awt.geom.Point2D origin)Gets the current bounding box of the particle, depending on its spawn location.- Parameters:
origin- the spawn location of this particle- Returns:
- The Rectangular particle bounding box.
getCollisionType
getColor
public java.awt.Color getColor()getDeltaHeight
public float getDeltaHeight()getDeltaWidth
public float getDeltaWidth()getVelocityX
public float getVelocityX()getVelocityY
public float getVelocityY()getAccelerationX
public float getAccelerationX()getAccelerationY
public float getAccelerationY()getAngle
public float getAngle()getDeltaAngle
public float getDeltaAngle()getHeight
public float getHeight()isOutlineOnly
public boolean isOutlineOnly()isAntiAliased
public boolean isAntiAliased()getOpacity
public float getOpacity()getRenderLocation
public java.awt.geom.Point2D getRenderLocation(java.awt.geom.Point2D effectLocation)Gets the location relative to the specified effect location.- Parameters:
effectLocation- the effect position- Returns:
- the location
getCustomRenderType
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.
getWidth
public float getWidth()getX
public float getX()getY
public float getY()isFading
public boolean isFading()isFadingOnCollision
public boolean isFadingOnCollision()isContinuousCollisionEnabled
public boolean isContinuousCollisionEnabled()isStoppingOnCollision
public boolean isStoppingOnCollision()render
public abstract void render(java.awt.Graphics2D g, java.awt.geom.Point2D emitterOrigin)setCollisionType
setContinuousCollision
Enabling this check can be very performance hungry and should be used with caution and only for a small amount of particles.- Parameters:
ccd- If set to true, the collision will be checked continuously by a ray-cast approximation.- Returns:
- This particle instance.
setStopOnCollision
public void setStopOnCollision(boolean stopOnCollision)setColor
setDeltaHeight
setAccelerationX
setAccelerationY
setAngle
setDeltaAngle
setDeltaWidth
setVelocityX
setVelocityY
setFade
setFadeOnCollision
setHeight
setOutlineOnly
setAntiAliasing
setCustomRenderType
setWidth
setX
setY
setTimeToLive
init
timeToLiveReached
public boolean timeToLiveReached()Description copied from interface:ITimeToLiveDetermines whether this instance has exceeded its time to live.- Specified by:
timeToLiveReachedin interfaceITimeToLive- Returns:
- True if the time to live was reached; otherwise false.
update
public void update(java.awt.geom.Point2D emitterOrigin, float updateRatio)Updates the effect's position, change in xCurrent, change in yCurrent, remaining lifetime, and color.- Parameters:
emitterOrigin- The currentEmitteroriginupdateRatio- The update ratio for this particle.
getAbsoluteLocation
public java.awt.geom.Point2D getAbsoluteLocation(java.awt.geom.Point2D effectLocation)getAbsoluteX
protected float getAbsoluteX(java.awt.geom.Point2D emitterOrigin)getAbsoluteY
protected float getAbsoluteY(java.awt.geom.Point2D emitterOrigin)usesCustomRenderType
public boolean usesCustomRenderType()
