Class LightSource

java.lang.Object
de.gurkenlabs.litiengine.entities.Entity
de.gurkenlabs.litiengine.entities.LightSource
All Implemented Interfaces:
EntityRenderedListener, EntityRenderListener, IEntity, IRenderable, Tweenable, EventListener

public class LightSource extends Entity implements IRenderable
This class represents a light source in an environment. It extends the Entity class and implements IRenderable interface. It provides methods to render light sources and shadows.
  • Field Details

  • Constructor Details

    • LightSource

      public LightSource(int intensity, Color lightColor, LightSource.Type shapeType, boolean activated)
      Constructor for the LightSource class.
      Parameters:
      intensity - The intensity of this instance.
      lightColor - The color of this instance.
      shapeType - The shape type of this instance.
      activated - A flag indicating whether this light is activated by default.
  • Method Details

    • activate

      public void activate()
      Activates the light source.
    • deactivate

      public void deactivate()
      Deactivates the light source.
    • getColor

      public Color getColor()
    • getGradientPaint

      public RadialGradientPaint getGradientPaint()
    • getIntensity

      public int getIntensity()
    • getLightShape

      public Shape getLightShape()
    • getLightShapeType

      public LightSource.Type getLightShapeType()
    • isActive

      public boolean isActive()
    • setColor

      public void setColor(Color color)
    • setIntensity

      public void setIntensity(int intensity)
    • setLightShapeType

      public void setLightShapeType(LightSource.Type shapeType)
    • setSize

      public void setSize(double width, double height)
      Description copied from interface: IEntity
      Sets the size of the entity.
      Specified by:
      setSize in interface IEntity
      Overrides:
      setSize in class Entity
      Parameters:
      width - The new width of the entity.
      height - The new height of the entity.
    • setLocation

      public void setLocation(Point2D location)
      Description copied from class: Entity
      Sets the map location.
      Specified by:
      setLocation in interface IEntity
      Overrides:
      setLocation in class Entity
      Parameters:
      location - the new map location
    • toggle

      public void toggle()
      Toggles the light source between active and inactive states.
    • sendMessage

      public String sendMessage(Object sender, String message)
      Description copied from interface: IEntity
      Sends a message from the specified sender to this entity.
      Specified by:
      sendMessage in interface IEntity
      Overrides:
      sendMessage in class Entity
      Parameters:
      sender - The sender of the message.
      message - The message to send.
      Returns:
      The response to the message.
    • render

      public void render(Graphics2D graphic)
      Description copied from interface: IRenderable
      Renders the visual contents of this instance onto the provided graphics context.

      If an Entity implements this interface, this method will be called right after the entity was rendered from the environment. Allowing for a custom rendering mechanism.

      This interface can be implemented in general by anything that should be rendered to the game's screen.

      Specified by:
      render in interface IRenderable
      Parameters:
      graphic - The current graphics object onto which this instance will render its visual contents.
      See Also: