Class CreatureShadowImageEffect

java.lang.Object
de.gurkenlabs.litiengine.graphics.ImageEffect
de.gurkenlabs.litiengine.graphics.CreatureShadowImageEffect
All Implemented Interfaces:
ITimeToLive, Comparable<ImageEffect>

public class CreatureShadowImageEffect extends ImageEffect
Represents an image effect that applies a shadow to a creature. Extends the ImageEffect class.
  • Constructor Details

    • CreatureShadowImageEffect

      public CreatureShadowImageEffect(Creature creature)
      Initializes a new instance of the CreatureShadowImageEffect.
      Parameters:
      creature - The creature to which this affect will be applied to.
    • CreatureShadowImageEffect

      public CreatureShadowImageEffect(Creature creature, Color shadowColor)
      Initializes a new instance of the CreatureShadowImageEffect.
      Parameters:
      creature - The creature to which this affect will be applied to.
      shadowColor - The color of the shadow.
  • Method Details

    • getCreature

      public Creature getCreature()
      Gets the creature associated with this image effect.
      Returns:
      the creature associated with this image effect
    • getOffsetX

      public float getOffsetX()
      Gets the horizontal offset for the shadow.
      Returns:
      the horizontal offset for the shadow
    • setOffsetX

      public CreatureShadowImageEffect setOffsetX(float offsetX)
      Sets the horizontal offset for the shadow.
      Parameters:
      offsetX - the new horizontal offset for the shadow
      Returns:
      the updated CreatureShadowImageEffect instance
    • getOffsetY

      public float getOffsetY()
      Gets the vertical offset for the shadow.
      Returns:
      the vertical offset for the shadow
    • setOffsetY

      public CreatureShadowImageEffect setOffsetY(float offsetY)
      Sets the vertical offset for the shadow.
      Parameters:
      offsetY - the new vertical offset for the shadow
      Returns:
      the updated CreatureShadowImageEffect instance
    • apply

      public BufferedImage apply(BufferedImage image)
      Applies the shadow effect to the specified BufferedImage.
      Specified by:
      apply in class ImageEffect
      Parameters:
      image - the BufferedImage to apply the effect to
      Returns:
      the BufferedImage with the shadow effect applied
    • getShadowEllipse

      protected Ellipse2D getShadowEllipse(float spriteWidth, float spriteHeight, float offsetX, float offsetY)
      Creates an ellipse representing the shadow based on the sprite dimensions and offsets.
      Parameters:
      spriteWidth - the width of the sprite
      spriteHeight - the height of the sprite
      offsetX - the horizontal offset for the shadow
      offsetY - the vertical offset for the shadow
      Returns:
      an Ellipse2D object representing the shadow
    • drawShadow

      protected void drawShadow(Graphics2D graphics, float spriteWidth, float spriteHeight, float offsetX, float offsetY)
      Draws the shadow on the specified Graphics2D context.
      Parameters:
      graphics - the Graphics2D context to draw the shadow on
      spriteWidth - the width of the sprite
      spriteHeight - the height of the sprite
      offsetX - the horizontal offset for the shadow
      offsetY - the vertical offset for the shadow