Class ParticleEffectRenderer

java.lang.Object
com.csse3200.game.particles.ParticleEffectRenderer
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, Renderable, Comparable<Renderable>

public class ParticleEffectRenderer extends Object implements Renderable, com.badlogic.gdx.utils.Disposable
Renders a particle effect and frees it when completed.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ParticleEffectRenderer(com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect pooledEffect)
    Initialise to render a given pooled particle effect on PARTICLE_LAYER layer.
    ParticleEffectRenderer(com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect pooledEffect, int layer)
    Initialise to render a given pooled particle effect on a specified layer.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Allows the completion of the particle effect.
    int
     
    void
    Frees the particle effect from its pool and unregisters this from the render service.
    com.badlogic.gdx.graphics.g2d.ParticleEffect
    Get the underlying ParticleEffect.
    int
    Layer to be rendered in.
    float
    Z index controls rendering order within a layer.
    boolean
    Returns whether the underlying particle effect has completed.
    void
    render(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
    Updates and renders the particle effect.
    void
    setPosition(float x, float y)
    Sets the position of the particle effect.
    void
    setPosition(com.badlogic.gdx.math.Vector2 position)
    Sets the position of the particle effect.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ParticleEffectRenderer

      public ParticleEffectRenderer(com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect pooledEffect, int layer)
      Initialise to render a given pooled particle effect on a specified layer. Requires the render service to be initialised.
      Parameters:
      pooledEffect - the particle effect to be rendered.
      layer - the layer to render to.
    • ParticleEffectRenderer

      public ParticleEffectRenderer(com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect pooledEffect)
      Initialise to render a given pooled particle effect on PARTICLE_LAYER layer.
      Parameters:
      pooledEffect - the particle effect to be rendered.
  • Method Details

    • render

      public void render(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Updates and renders the particle effect. If the effect is complete, will dispose.
      Specified by:
      render in interface Renderable
      Parameters:
      batch - Batch to render to.
    • getEffect

      public com.badlogic.gdx.graphics.g2d.ParticleEffect getEffect()
      Get the underlying ParticleEffect. Null if completed.
      Returns:
      the particle effect
    • compareTo

      public int compareTo(Renderable o)
      Specified by:
      compareTo in interface Comparable<Renderable>
    • getZIndex

      public float getZIndex()
      Description copied from interface: Renderable
      Z index controls rendering order within a layer. Higher Z index is drawn on top.
      Specified by:
      getZIndex in interface Renderable
      Returns:
      Z index
    • getLayer

      public int getLayer()
      Description copied from interface: Renderable
      Layer to be rendered in. Higher layers will be rendered on top of lower layers.
      Specified by:
      getLayer in interface Renderable
      Returns:
      layer
    • setPosition

      public void setPosition(com.badlogic.gdx.math.Vector2 position)
      Sets the position of the particle effect.
      Parameters:
      position - the position to set to.
    • setPosition

      public void setPosition(float x, float y)
      Sets the position of the particle effect.
      Parameters:
      x - the x coordinate.
      y - the y coordinate.
    • allowCompletion

      public void allowCompletion()
      Allows the completion of the particle effect.
    • isValid

      public boolean isValid()
      Returns whether the underlying particle effect has completed.
      Returns:
      true if the particle effect has completed.
    • dispose

      public void dispose()
      Frees the particle effect from its pool and unregisters this from the render service.
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable