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 ITimeToLive
Constructor Summary
Constructors Constructor Description Particle(float width, float height)
Constructs a new particle.Method Summary
Modifier and Type Method Description java.awt.geom.Point2D
getAbsoluteLocation(java.awt.geom.Point2D effectLocation)
protected float
getAbsoluteX(java.awt.geom.Point2D emitterOrigin)
protected float
getAbsoluteY(java.awt.geom.Point2D emitterOrigin)
float
getAccelerationX()
float
getAccelerationY()
long
getAliveTime()
Gets the time this instance is alive.float
getAngle()
java.awt.geom.Rectangle2D
getBoundingBox(java.awt.geom.Point2D origin)
Gets the current bounding box of the particle, depending on its spawn location.Collision
getCollisionType()
java.awt.Color
getColor()
RenderType
getCustomRenderType()
float
getDeltaAngle()
float
getDeltaHeight()
float
getDeltaWidth()
float
getHeight()
float
getOpacity()
java.awt.geom.Point2D
getRenderLocation(java.awt.geom.Point2D effectLocation)
Gets the location relative to the specified effect location.int
getTimeToLive()
Gets the total time to live of this instance.float
getVelocityX()
float
getVelocityY()
float
getWidth()
float
getX()
float
getY()
Particle
init(EmitterData data)
boolean
isAntiAliased()
boolean
isContinuousCollisionEnabled()
boolean
isFading()
boolean
isFadingOnCollision()
boolean
isOutlineOnly()
boolean
isStoppingOnCollision()
abstract void
render(java.awt.Graphics2D g, java.awt.geom.Point2D emitterOrigin)
Particle
setAccelerationX(float accelerationX)
Particle
setAccelerationY(float accelerationY)
Particle
setAngle(float angle)
Particle
setAntiAliasing(boolean antiAliasing)
Particle
setCollisionType(Collision collisionType)
Particle
setColor(java.awt.Color color)
Particle
setContinuousCollision(boolean ccd)
Enabling this check can be very performance hungry and should be used with caution and only for a small amount of particles.Particle
setCustomRenderType(RenderType renderType)
Particle
setDeltaAngle(float deltaAngle)
Particle
setDeltaHeight(float deltaHeight)
Particle
setDeltaWidth(float deltaWidth)
Particle
setFade(boolean fade)
Particle
setFadeOnCollision(boolean fadeOnCollision)
Particle
setHeight(float height)
Particle
setOutlineOnly(boolean outlineOnly)
void
setStopOnCollision(boolean stopOnCollision)
Particle
setTimeToLive(int ttl)
Particle
setVelocityX(float velocityX)
Particle
setVelocityY(float velocityY)
Particle
setWidth(float width)
Particle
setX(float x)
Particle
setY(float y)
boolean
timeToLiveReached()
Determines whether this instance has exceeded its time to live.void
update(java.awt.geom.Point2D emitterOrigin, float updateRatio)
Updates the effect's position, change in xCurrent, change in yCurrent, remaining lifetime, and color.boolean
usesCustomRenderType()
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:ITimeToLive
Gets the time this instance is alive.- Specified by:
getAliveTime
in 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:ITimeToLive
Gets the total time to live of this instance.- Specified by:
getTimeToLive
in 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:ITimeToLive
Determines whether this instance has exceeded its time to live.- Specified by:
timeToLiveReached
in 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 currentEmitter
originupdateRatio
- 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()