Class LightSource
java.lang.Object
de.gurkenlabs.litiengine.entities.Entity
de.gurkenlabs.litiengine.entities.LightSource
- All Implemented Interfaces:
EntityRenderedListener,EntityRenderListener,IEntity,IRenderable,Tweenable,EventListener
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum representing the type of light source. -
Field Summary
FieldsFields inherited from class de.gurkenlabs.litiengine.entities.Entity
ANY_MESSAGE -
Constructor Summary
ConstructorsConstructorDescriptionLightSource(int intensity, Color lightColor, LightSource.Type shapeType, boolean activated) Constructor for the LightSource class. -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Activates the light source.voidDeactivates the light source.getColor()intbooleanisActive()voidrender(Graphics2D graphic) Renders the visual contents of this instance onto the provided graphics context.sendMessage(Object sender, String message) Sends a message from the specified sender to this entity.voidvoidsetIntensity(int intensity) voidsetLightShapeType(LightSource.Type shapeType) voidsetLocation(Point2D location) Sets the map location.voidsetSize(double width, double height) Sets the size of the entity.voidtoggle()Toggles the light source between active and inactive states.Methods inherited from class de.gurkenlabs.litiengine.entities.Entity
actions, addController, addEntityRenderListener, addListener, addTag, addTransformListener, animations, attachControllers, behavior, canRender, detachControllers, getAngle, getBoundingBox, getCenter, getController, getControllers, getEnvironment, getHeight, getLocation, getMapId, getName, getProperties, getRenderType, getTags, getTweenValues, getWidth, getX, getY, hasTag, isLoaded, isVisible, loaded, onMessage, onMessage, onRendered, perform, register, removed, removeListener, removeListener, removeListener, removeListener, removeListener, removeTag, rendered, rendering, renderWithLayer, setAngle, setController, setHeight, setLocation, setMapId, setName, setRenderType, setRenderWithLayer, setTweenValues, setVisible, setWidth, setX, setY, toString
-
Field Details
-
TOGGLE_MESSAGE
- See Also:
-
DEFAULT_INTENSITY
public static final int DEFAULT_INTENSITY- See Also:
-
-
Constructor Details
-
LightSource
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
-
getGradientPaint
-
getIntensity
public int getIntensity() -
getLightShape
-
getLightShapeType
-
isActive
public boolean isActive() -
setColor
-
setIntensity
public void setIntensity(int intensity) -
setLightShapeType
-
setSize
public void setSize(double width, double height) Description copied from interface:IEntitySets the size of the entity. -
setLocation
Description copied from class:EntitySets the map location.- Specified by:
setLocationin interfaceIEntity- Overrides:
setLocationin classEntity- Parameters:
location- the new map location
-
toggle
public void toggle()Toggles the light source between active and inactive states. -
sendMessage
Description copied from interface:IEntitySends a message from the specified sender to this entity.- Specified by:
sendMessagein interfaceIEntity- Overrides:
sendMessagein classEntity- Parameters:
sender- The sender of the message.message- The message to send.- Returns:
- The response to the message.
-
render
Description copied from interface:IRenderableRenders the visual contents of this instance onto the provided graphics context.If an
Entityimplements 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:
renderin interfaceIRenderable- Parameters:
graphic- The current graphics object onto which this instance will render its visual contents.- See Also:
-