Class RenderEngine
Environment and with respect to the
Camera location and zoom.
Internally, it uses the static renderer implementations to actually execute the rendering process. This class basically prepares the specified render subject and passed them to a renderer with the current correct context.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionYou should never call this manually! Instead use theGame.graphics()instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specified entity rendered listener to receive events when entities were rendered.voidaddEntityRenderListener(EntityRenderListener listener) Adds the specified entity render listener to receive events and callbacks about the rendering process of entities.booleanDetermines whether the specified entity can be rendered by evaluating the callbacks to all registeredEntityRenderListeners.floatGets the base render scale of the game.voidRemoves the specified entity rendered listener.voidRemoves the specified entity render listener.voidrenderEntities(Graphics2D g, Collection<? extends IEntity> entities) Renders the specified entities at their current location in the environment.voidrenderEntities(Graphics2D g, Collection<? extends IEntity> entities, boolean sort) Renders the specified entities at their current location in the environment.voidrenderEntity(Graphics2D g, IEntity entity) Renders the specified entity at its current location in the environment.voidrenderImage(Graphics2D g, Image image, double x, double y) Renders the specified image at the defined map location.voidrenderImage(Graphics2D g, Image image, Point2D location) Renders the specified image at the defined map location.voidrenderOutline(Graphics2D g, Shape shape) Renders the outline of the specified shape to the translated location in the game world.voidrenderOutline(Graphics2D g, Shape shape, boolean antialiasing) Renders the outline of the specified shape to the translated location in the game world.voidrenderOutline(Graphics2D g, Shape shape, Stroke stroke) Renders the outline with the definedStrokeof the specified shape to the translated location in the game world.voidrenderOutline(Graphics2D g, Shape shape, Stroke stroke, boolean antialiasing) Renders the outline with the definedStrokeof the specified shape to the translated location in the game world.voidrenderOutline(Graphics2D g, Shape shape, Stroke stroke, boolean antialiasing, double angle) Renders the outline with the definedStrokeof the specified shape to the translated location in the game world.voidrenderShape(Graphics2D g, Shape shape) Renders the specified shape to the translated location in the game world.voidrenderShape(Graphics2D g, Shape shape, boolean antialiasing) Renders the specified shape to the translated location in the game world.voidrenderShape(Graphics2D g, Shape shape, boolean antialiasing, double angle) Renders the specified shape to the translated location in the game world.voidrenderText(Graphics2D g, String text, double x, double y) Renders the specified text to the defined map location.voidrenderText(Graphics2D g, String text, double x, double y, boolean antialias) Renders the specified text to the defined map location.voidrenderText(Graphics2D g, String text, Point2D location) Renders the specified text to the defined map location.voidrenderText(Graphics2D g, String text, Point2D location, boolean antialias) Renders the specified text to the defined map location.voidsetBaseRenderScale(float scale) Sets the global base scale that is used to calculate the actual render scale of the game.
-
Field Details
-
DEFAULT_RENDERSCALE
public static final float DEFAULT_RENDERSCALE- See Also:
-
-
Constructor Details
-
RenderEngine
public RenderEngine()You should never call this manually! Instead use theGame.graphics()instance.- See Also:
-
-
Method Details
-
addEntityRenderedListener
Adds the specified entity rendered listener to receive events when entities were rendered.This is the global equivalent to
IEntity.addEntityRenderedListener- Parameters:
listener- The listener to add.- See Also:
-
removeEntityRenderedListener
Removes the specified entity rendered listener.- Parameters:
listener- The listener to remove.
-
addEntityRenderListener
Adds the specified entity render listener to receive events and callbacks about the rendering process of entities.This is the global equivalent to
IEntity.addEntityRenderListener- Parameters:
listener- The listener to add.- See Also:
-
removeEntityRenderListener
Removes the specified entity render listener.- Parameters:
listener- The listener to remove.
-
getBaseRenderScale
public float getBaseRenderScale()Gets the base render scale of the game.- Returns:
- The base render scale.
-
setBaseRenderScale
public void setBaseRenderScale(float scale) Sets the global base scale that is used to calculate the actual render scale of the game.- Parameters:
scale- The base render scale for the game.- See Also:
-
renderText
Renders the specified text to the defined map location.- Parameters:
g- The graphics object to render on.text- The text to be renderedx- The x-coordinate of the text.y- The y-coordinate of the textantialias- Configure whether or not to render the text with antialiasing.
-
renderText
Renders the specified text to the defined map location.- Parameters:
g- The graphics object to render on.text- The text to be renderedx- The x-coordinate of the text.y- The y-coordinate of the text
-
renderText
Renders the specified text to the defined map location.- Parameters:
g- The graphics object to render on.text- The text to be rendered.location- The location on the map.antialias- Configure whether or not to render the text with antialiasing.
-
renderText
Renders the specified text to the defined map location.- Parameters:
g- The graphics object to render on.text- The text to be rendered.location- The location on the map.
-
renderShape
Renders the specified shape to the translated location in the game world.- Parameters:
g- The graphics object to render on.shape- The shape to be rendered.
-
renderShape
Renders the specified shape to the translated location in the game world.- Parameters:
g- The graphics object to render on.shape- The shape to be rendered.antialiasing- Configure whether or not to render the shape with antialiasing.
-
renderShape
Renders the specified shape to the translated location in the game world.- Parameters:
g- The graphics object to render on.shape- The shape to be rendered.antialiasing- Configure whether or not to render the shape with antialiasing.angle- The angle by which the shape will be rotated.
-
renderOutline
Renders the outline of the specified shape to the translated location in the game world.- Parameters:
g- The graphics object to render on.shape- The shape to be rendered.
-
renderOutline
Renders the outline of the specified shape to the translated location in the game world.- Parameters:
g- The graphics object to render on.shape- The shape to be rendered.antialiasing- Configure whether or not to render the shape with antialiasing.
-
renderOutline
Renders the outline with the definedStrokeof the specified shape to the translated location in the game world.- Parameters:
g- The graphics object to render on.shape- The shape to be rendered.stroke- The stroke that is used to render the shape.- See Also:
-
renderOutline
Renders the outline with the definedStrokeof the specified shape to the translated location in the game world.- Parameters:
g- The graphics object to render on.shape- The shape to be rendered.stroke- The stroke that is used to render the shape.antialiasing- Configure whether or not to render the shape with antialiasing.- See Also:
-
renderOutline
public void renderOutline(Graphics2D g, Shape shape, Stroke stroke, boolean antialiasing, double angle) Renders the outline with the definedStrokeof the specified shape to the translated location in the game world.- Parameters:
g- The graphics object to render on.shape- The shape to be rendered.stroke- The stroke that is used to render the shape.antialiasing- Configure whether or not to render the shape with antialiasing.angle- The angle by which the shape will be rotated.- See Also:
-
renderImage
Renders the specified image at the defined map location.- Parameters:
g- The graphics object to render on.image- The image to be rendered.x- The x-coordinate of the image.y- The y-coordinate of the image
-
renderImage
Renders the specified image at the defined map location.- Parameters:
g- The graphics object to render on.image- The image to be rendered.location- The location of the image.
-
renderEntities
Renders the specified entities at their current location in the environment.- Parameters:
g- The graphics object to render on.entities- The entities to be rendered.
-
renderEntities
Renders the specified entities at their current location in the environment.This method sorts the specified entities by their y-coordinate unless the
sortparameter is set to false.- Parameters:
g- The graphics object to render on.entities- The entities to be rendered.sort- Defines whether the entities should be sorted by theEntityYComparatorto simulate 2.5D graphics.- See Also:
-
renderEntity
Renders the specified entity at its current location in the environment.This method uses the
IEntityAnimationControllerto render the appropriateAnimation.
If the entity implements theIRenderableinterface, its render method is being called afterwards.To listen to events about this process, you can add a
EntityRenderListenerorEntityRenderedListenerto the render engine.- Parameters:
g- The graphics object to render on.entity- The entity to be rendered.- See Also:
-
canRender
Determines whether the specified entity can be rendered by evaluating the callbacks to all registeredEntityRenderListeners.If the
RenderTypeof the specified entity is set toNONEor there are any callbacks that prevent the entity from being rendered, this method will return false.- Parameters:
entity- The entity to check whether it can be rendered or not.- Returns:
- True if the entity can be rendered; otherwise false.
- See Also:
-