Package com.csse3200.game.services
Class ParticleService
java.lang.Object
com.csse3200.game.services.ParticleService
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum for each type of particle effect known to the particle system -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a particle service, loading in all particle effect assets and creating pools for those particle effects. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddComponent(ParticleEffectComponent component) Adds aParticleEffectComponentto theListofParticleEffectComponents tracked by theParticleServiceso that it can render each individual effect.com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffectgetEffect(ParticleService.ParticleEffectType effectType) Obtains the pooled particle effect for a givenParticleService.ParticleEffectTypevoidremoveComponent(ParticleEffectComponent component) Removes aParticleEffectComponentto theListofParticleEffectComponents tracked by theParticleServiceso that it can render each individual effect.voidrender(com.badlogic.gdx.graphics.g2d.SpriteBatch batch, float delta) Renders the queued particle effectsvoidstartEffect(ParticleService.ParticleEffectType effectType) Starts a particle effect, creating an effect wrapper and adding it to the queuevoidstartEffectAtPosition(ParticleService.ParticleEffectType effectType, com.badlogic.gdx.math.Vector2 position) Starts rendering aParticleEffectPool.PooledEffectat a givenVector2positionvoidstopEffect(ParticleService.ParticleEffectType effectType) Stops a particle effect, freeing the effect and removing it from the queuevoidstopEffectCategory(String category) Stops all particle effects by category in the render queue
-
Field Details
-
WEATHER_EVENT
- See Also:
-
ENTITY_EFFECT
- See Also:
-
START_EVENT
- See Also:
-
STOP_EVENT
- See Also:
-
-
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 effectsdelta- delta time value used to update the particle effects
-
startEffect
Starts a particle effect, creating an effect wrapper and adding it to the queue- Parameters:
effectType- type of effect to start
-
stopEffect
Stops a particle effect, freeing the effect and removing it from the queue- Parameters:
effectType- type of effect to stop
-
stopEffectCategory
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 givenParticleService.ParticleEffectType- Parameters:
effectType- TheParticleService.ParticleEffectTypeof theParticleEffectPool.PooledEffectto be obtained- Returns:
- The
ParticleEffectPool.PooledEffectthat is used to render the effect
-
startEffectAtPosition
public void startEffectAtPosition(ParticleService.ParticleEffectType effectType, com.badlogic.gdx.math.Vector2 position) Starts rendering aParticleEffectPool.PooledEffectat a givenVector2position- Parameters:
effectType- TheParticleService.ParticleEffectTypeof the particle to be renderedposition- position to render the particle effect at
-
addComponent
Adds aParticleEffectComponentto theListofParticleEffectComponents tracked by theParticleServiceso that it can render each individual effect.- Parameters:
component- component to be added
-
removeComponent
Removes aParticleEffectComponentto theListofParticleEffectComponents tracked by theParticleServiceso that it can render each individual effect.- Parameters:
component- component to be removed
-