Class ItemEffectsService

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

public class ItemEffectsService extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 animation
      animatorName - 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 == NORMAL
      playMode - 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 name
      position - World position at which the item was placed (centre of tile)
      tileSize - Tile size of the level used to scale the effect
      bottomCorner - Target position (bottom right corner) for moving effects