Package com.csse3200.game.services
Class ItemEffectsService
java.lang.Object
com.csse3200.game.services.ItemEffectsService
ItemEffectsService is a centralised helper for spawning animations for Items used in-level.
Effects are implemented as an Entity with an AnimationRenderComponent.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
playEffect
(String itemName, com.badlogic.gdx.math.Vector2 position, int tileSize, com.badlogic.gdx.math.Vector2 bottomCorner) Handles call to play a particular effect and then calls to spawn effect.static void
spawnEffect
(com.badlogic.gdx.graphics.g2d.TextureAtlas atlas, String animatorName, com.badlogic.gdx.math.Vector2[] positions, int scale, float[] frameAndEffectDuration, com.badlogic.gdx.graphics.g2d.Animation.PlayMode playMode, boolean movingAnimation) Spawns the animation effect for the particular Item.
-
Constructor Details
-
ItemEffectsService
public ItemEffectsService()
-
-
Method Details
-
spawnEffect
public static void spawnEffect(com.badlogic.gdx.graphics.g2d.TextureAtlas atlas, String animatorName, com.badlogic.gdx.math.Vector2[] positions, int scale, float[] frameAndEffectDuration, com.badlogic.gdx.graphics.g2d.Animation.PlayMode playMode, boolean movingAnimation) Spawns the animation effect for the particular Item.- Parameters:
atlas
- Texture atlas that contains the frames for the animationanimatorName
- Name of the animation.positions
- positions[0] is initial world position where the effect entity is spawned, and positions[1] is destination position when movingAnimation is true (value is ignored otherwise)scale
- Uniform scale applied to the effect (world units)frameAndEffectDuration
- frameAndEffectDuration[0] is duration per animation frame (seconds), and frameAndEffectDuration[1] is total lifetime of the effect (seconds) when playMode == NORMALplayMode
- Animation PlayMode (eg NORMAL, LOOP etc)movingAnimation
- If true the effect will move from position to finalPosition
-
playEffect
public void playEffect(String itemName, com.badlogic.gdx.math.Vector2 position, int tileSize, com.badlogic.gdx.math.Vector2 bottomCorner) Handles call to play a particular effect and then calls to spawn effect.- Parameters:
itemName
- Effect nameposition
- World position at which the item was placed (centre of tile)tileSize
- Tile size of the level used to scale the effectbottomCorner
- Target position (bottom right corner) for moving effects
-