Package com.csse3200.game.services
Class ParticleService
java.lang.Object
com.csse3200.game.services.ParticleService
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Enum 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 TypeMethodDescriptionvoid
addComponent
(ParticleEffectComponent component) Adds aParticleEffectComponent
to theList
ofParticleEffectComponent
s tracked by theParticleService
so that it can render each individual effect.com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect
getEffect
(ParticleService.ParticleEffectType effectType) Obtains the pooled particle effect for a givenParticleService.ParticleEffectType
void
removeComponent
(ParticleEffectComponent component) Removes aParticleEffectComponent
to theList
ofParticleEffectComponent
s tracked by theParticleService
so that it can render each individual effect.void
render
(com.badlogic.gdx.graphics.g2d.SpriteBatch batch, float delta) Renders the queued particle effectsvoid
startEffect
(ParticleService.ParticleEffectType effectType) Starts a particle effect, creating an effect wrapper and adding it to the queuevoid
startEffectAtPosition
(ParticleService.ParticleEffectType effectType, com.badlogic.gdx.math.Vector2 position) Starts rendering aParticleEffectPool.PooledEffect
at a givenVector2
positionvoid
stopEffect
(ParticleService.ParticleEffectType effectType) Stops a particle effect, freeing the effect and removing it from the queuevoid
stopEffectCategory
(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.ParticleEffectType
of theParticleEffectPool.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 aParticleEffectPool.PooledEffect
at a givenVector2
position- Parameters:
effectType
- TheParticleService.ParticleEffectType
of the particle to be renderedposition
- position to render the particle effect at
-
addComponent
Adds aParticleEffectComponent
to theList
ofParticleEffectComponent
s tracked by theParticleService
so that it can render each individual effect.- Parameters:
component
- component to be added
-
removeComponent
Removes aParticleEffectComponent
to theList
ofParticleEffectComponent
s tracked by theParticleService
so that it can render each individual effect.- Parameters:
component
- component to be removed
-