Class ParticleService

java.lang.Object
com.csse3200.game.services.ParticleService

public class ParticleService extends Object
  • Field Details

  • Constructor Details

    • ParticleService

      public ParticleService()
      Creates a particle service, loading in all particle effect assets and creating pools for those particle effects.
  • Method Details

    • render

      public void render(com.badlogic.gdx.graphics.g2d.SpriteBatch batch, float delta)
      Renders the queued particle effects
      Parameters:
      batch - sprite batch used to render effects
      delta - delta time value used to update the particle effects
    • startEffect

      public void startEffect(ParticleService.ParticleEffectType effectType)
      Starts a particle effect, creating an effect wrapper and adding it to the queue
      Parameters:
      effectType - type of effect to start
    • stopEffect

      public void stopEffect(ParticleService.ParticleEffectType effectType)
      Stops a particle effect, freeing the effect and removing it from the queue
      Parameters:
      effectType - type of effect to stop
    • stopEffectCategory

      public void stopEffectCategory(String category)
      Stops all particle effects by category in the render queue
      Parameters:
      category - category of particle effects
    • getEffect

      public com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect getEffect(ParticleService.ParticleEffectType effectType)
      Obtains the pooled particle effect for a given ParticleService.ParticleEffectType
      Parameters:
      effectType - The ParticleService.ParticleEffectType of the ParticleEffectPool.PooledEffect to be obtained
      Returns:
      The ParticleEffectPool.PooledEffect that is used to render the effect
    • startEffectAtPosition

      public void startEffectAtPosition(ParticleService.ParticleEffectType effectType, com.badlogic.gdx.math.Vector2 position)
      Starts rendering a ParticleEffectPool.PooledEffect at a given Vector2 position
      Parameters:
      effectType - The ParticleService.ParticleEffectType of the particle to be rendered
      position - position to render the particle effect at
    • addComponent

      public void addComponent(ParticleEffectComponent component)
      Adds a ParticleEffectComponent to the List of ParticleEffectComponents tracked by the ParticleService so that it can render each individual effect.
      Parameters:
      component - component to be added
    • removeComponent

      public void removeComponent(ParticleEffectComponent component)
      Removes a ParticleEffectComponent to the List of ParticleEffectComponents tracked by the ParticleService so that it can render each individual effect.
      Parameters:
      component - component to be removed