Class CreatureShadowImageEffect
java.lang.Object
de.gurkenlabs.litiengine.graphics.ImageEffect
de.gurkenlabs.litiengine.graphics.CreatureShadowImageEffect
- All Implemented Interfaces:
ITimeToLive, Comparable<ImageEffect>
Represents an image effect that applies a shadow to a creature. Extends the ImageEffect class.
-
Constructor Summary
ConstructorsConstructorDescriptionCreatureShadowImageEffect(Creature creature) Initializes a new instance of theCreatureShadowImageEffect.CreatureShadowImageEffect(Creature creature, Color shadowColor) Initializes a new instance of theCreatureShadowImageEffect. -
Method Summary
Modifier and TypeMethodDescriptionapply(BufferedImage image) Applies the shadow effect to the specified BufferedImage.protected voiddrawShadow(Graphics2D graphics, float spriteWidth, float spriteHeight, float offsetX, float offsetY) Draws the shadow on the specified Graphics2D context.Gets the creature associated with this image effect.floatGets the horizontal offset for the shadow.floatGets the vertical offset for the shadow.protected Ellipse2DgetShadowEllipse(float spriteWidth, float spriteHeight, float offsetX, float offsetY) Creates an ellipse representing the shadow based on the sprite dimensions and offsets.setOffsetX(float offsetX) Sets the horizontal offset for the shadow.setOffsetY(float offsetY) Sets the vertical offset for the shadow.Methods inherited from class ImageEffect
compareTo, equals, getAliveTime, getName, getPriority, getTimeToLive, hashCode, setName, setPriority, timeToLiveReached
-
Constructor Details
-
CreatureShadowImageEffect
Initializes a new instance of theCreatureShadowImageEffect.- Parameters:
creature- The creature to which this affect will be applied to.
-
CreatureShadowImageEffect
-
-
Method Details
-
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
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
Sets the vertical offset for the shadow.- Parameters:
offsetY- the new vertical offset for the shadow- Returns:
- the updated CreatureShadowImageEffect instance
-
apply
Applies the shadow effect to the specified BufferedImage.- Specified by:
applyin classImageEffect- 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 spritespriteHeight- the height of the spriteoffsetX- the horizontal offset for the shadowoffsetY- 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 onspriteWidth- the width of the spritespriteHeight- the height of the spriteoffsetX- the horizontal offset for the shadowoffsetY- the vertical offset for the shadow
-