Package com.deco2800.game.rendering
Class ParticleRenderComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.rendering.RenderComponent
com.deco2800.game.rendering.ParticleRenderComponent
- All Implemented Interfaces:
Disposable
,Renderable
,java.lang.Comparable<Renderable>
public class ParticleRenderComponent extends RenderComponent
Render particle effect for entities.
Usages: ParticleRenderComponent particle = new ParticleRenderComponent("path.party"); entity.addComponent(particle);
Start particle effect: particle.startEffect();
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ParticleRenderComponent(java.lang.String texturePath)
Constructor of particle effect -
Method Summary
Modifier and Type Method Description void
create()
Called when the entity is created and registered.void
dispose()
Called when the component is disposed.protected void
draw(SpriteBatch batch)
Draw the renderable.float
getParticlePlayTime()
Get the playing time of the animationfloat
getZIndex()
Set the zIndex of the entity according to the y coordinate of the entity and the original zIndex.boolean
isEffectStart()
get if the particle effect is start, for test.void
startEffect()
Start the particle effect on this entityMethods inherited from class com.deco2800.game.rendering.RenderComponent
compareTo, getLayer, render
Methods inherited from class com.deco2800.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
ParticleRenderComponent
public ParticleRenderComponent(java.lang.String texturePath)Constructor of particle effect- Parameters:
texturePath
- the path of .party file
-
-
Method Details
-
create
public void create()Description copied from class:Component
Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.- Overrides:
create
in classRenderComponent
-
getZIndex
public float getZIndex()Set the zIndex of the entity according to the y coordinate of the entity and the original zIndex.If zIndex is not set originally, then The smaller the Y value, the higher the Z index, so that closer entities are drawn in front.
If zIndex has been set, zIndex will not change.
- Specified by:
getZIndex
in interfaceRenderable
- Overrides:
getZIndex
in classRenderComponent
- Returns:
- The drawing priority of the current entity
-
isEffectStart
public boolean isEffectStart()get if the particle effect is start, for test.- Returns:
-
startEffect
public void startEffect()Start the particle effect on this entity -
draw
Description copied from class:RenderComponent
Draw the renderable. Should be called only by the renderer, not manually.- Specified by:
draw
in classRenderComponent
- Parameters:
batch
- Batch to render to.
-
getParticlePlayTime
public float getParticlePlayTime()Get the playing time of the animation- Returns:
- float The time the animation has been played (seconds).
-
dispose
public void dispose()Description copied from class:Component
Called when the component is disposed. Dispose of any internal resources here.- Specified by:
dispose
in interfaceDisposable
- Overrides:
dispose
in classRenderComponent
-