public final class RenderEngine
extends java.lang.Object
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.
Modifier and Type | Field and Description |
---|---|
static float |
DEFAULT_RENDERSCALE |
Constructor and Description |
---|
RenderEngine()
You should never call this manually! Instead use the
Game.graphics() instance. |
Modifier and Type | Method and Description |
---|---|
void |
addEntityRenderedListener(EntityRenderedListener listener)
Adds the specified entity rendered listener to receive events when entities were rendered.
|
void |
addEntityRenderListener(EntityRenderListener listener)
Adds the specified entity render listener to receive events and callbacks about the rendering process of entities.
|
boolean |
canRender(IEntity entity)
Determines whether the specified entity can be rendered by evaluating the callbacks to all registered
EntityRenderListeners . |
float |
getBaseRenderScale()
Gets the base render scale of the game.
|
void |
removeEntityRenderedListener(EntityRenderedListener listener)
Removes the specified entity rendered listener.
|
void |
removeEntityRenderListener(EntityRenderListener listener)
Removes the specified entity render listener.
|
void |
renderEntities(java.awt.Graphics2D g,
java.util.Collection<? extends IEntity> entities)
Renders the specified entities at their current location in the environment.
|
void |
renderEntities(java.awt.Graphics2D g,
java.util.Collection<? extends IEntity> entities,
boolean sort)
Renders the specified entities at their current location in the environment.
|
void |
renderEntity(java.awt.Graphics2D g,
IEntity entity)
Renders the specified entity at its current location in the environment.
|
void |
renderImage(java.awt.Graphics2D g,
java.awt.Image image,
double x,
double y)
Renders the specified image at the defined map location.
|
void |
renderImage(java.awt.Graphics2D g,
java.awt.Image image,
java.awt.geom.Point2D location)
Renders the specified image at the defined map location.
|
void |
renderOutline(java.awt.Graphics2D g,
java.awt.Shape shape)
Renders the outline of the specified shape to the translated location in the game world.
|
void |
renderOutline(java.awt.Graphics2D g,
java.awt.Shape shape,
boolean antialiasing)
Renders the outline of the specified shape to the translated location in the game world.
|
void |
renderOutline(java.awt.Graphics2D g,
java.awt.Shape shape,
java.awt.Stroke stroke)
Renders the outline with the defined
Stroke of the specified shape to the translated location in the game world. |
void |
renderOutline(java.awt.Graphics2D g,
java.awt.Shape shape,
java.awt.Stroke stroke,
boolean antialiasing)
Renders the outline with the defined
Stroke of the specified shape to the translated location in the game world. |
void |
renderShape(java.awt.Graphics2D g,
java.awt.Shape shape)
Renders the specified shape to the translated location in the game world.
|
void |
renderShape(java.awt.Graphics2D g,
java.awt.Shape shape,
boolean antialiasing)
Renders the specified shape to the translated location in the game world.
|
void |
renderText(java.awt.Graphics2D g,
java.lang.String text,
double x,
double y)
Renders the specified text to the defined map location.
|
void |
renderText(java.awt.Graphics2D g,
java.lang.String text,
double x,
double y,
boolean antialias)
Renders the specified text to the defined map location.
|
void |
renderText(java.awt.Graphics2D g,
java.lang.String text,
java.awt.geom.Point2D location)
Renders the specified text to the defined map location.
|
void |
renderText(java.awt.Graphics2D g,
java.lang.String text,
java.awt.geom.Point2D location,
boolean antialias)
Renders the specified text to the defined map location.
|
void |
setBaseRenderScale(float scale)
Sets the global base scale that is used to calculate the actual render scale of the game.
|
public static final float DEFAULT_RENDERSCALE
public RenderEngine()
You should never call this manually! Instead use the Game.graphics()
instance.
Game.graphics()
public void addEntityRenderedListener(EntityRenderedListener listener)
This is the global equivalent to IEntity.addEntityRenderedListener
listener
- The listener to add.IEntity.onRendered(EntityRenderedListener)
public void removeEntityRenderedListener(EntityRenderedListener listener)
listener
- The listener to remove.public void addEntityRenderListener(EntityRenderListener listener)
This is the global equivalent to IEntity.addEntityRenderListener
listener
- The listener to add.IEntity.addEntityRenderListener(EntityRenderListener)
public void removeEntityRenderListener(EntityRenderListener listener)
listener
- The listener to remove.public float getBaseRenderScale()
public void setBaseRenderScale(float scale)
scale
- The base render scale for the game.ICamera.getRenderScale()
public void renderText(java.awt.Graphics2D g, java.lang.String text, double x, double y, boolean antialias)
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.public void renderText(java.awt.Graphics2D g, java.lang.String text, double x, double y)
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 textpublic void renderText(java.awt.Graphics2D g, java.lang.String text, java.awt.geom.Point2D location, boolean antialias)
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.public void renderText(java.awt.Graphics2D g, java.lang.String text, java.awt.geom.Point2D location)
g
- The graphics object to render on.text
- The text to be rendered.location
- The location on the map.public void renderShape(java.awt.Graphics2D g, java.awt.Shape shape)
g
- The graphics object to render on.shape
- The shape to be rendered.public void renderShape(java.awt.Graphics2D g, java.awt.Shape shape, boolean antialiasing)
g
- The graphics object to render on.shape
- The shape to be rendered.antialiasing
- Configure whether or not to render the shape with antialiasing.public void renderOutline(java.awt.Graphics2D g, java.awt.Shape shape)
g
- The graphics object to render on.shape
- The shape to be rendered.public void renderOutline(java.awt.Graphics2D g, java.awt.Shape shape, boolean antialiasing)
g
- The graphics object to render on.shape
- The shape to be rendered.antialiasing
- Configure whether or not to render the shape with antialiasing.public void renderOutline(java.awt.Graphics2D g, java.awt.Shape shape, java.awt.Stroke stroke)
Stroke
of the specified shape to the translated location in the game world.g
- The graphics object to render on.shape
- The shape to be rendered.stroke
- The stroke that is used to render the shape.Stroke
public void renderOutline(java.awt.Graphics2D g, java.awt.Shape shape, java.awt.Stroke stroke, boolean antialiasing)
Stroke
of the specified shape to the translated location in the game world.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.Stroke
public void renderImage(java.awt.Graphics2D g, java.awt.Image image, double x, double y)
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 imagepublic void renderImage(java.awt.Graphics2D g, java.awt.Image image, java.awt.geom.Point2D location)
g
- The graphics object to render on.image
- The image to be rendered.location
- The location of the image.public void renderEntities(java.awt.Graphics2D g, java.util.Collection<? extends IEntity> entities)
g
- The graphics object to render on.entities
- The entities to be rendered.public void renderEntities(java.awt.Graphics2D g, java.util.Collection<? extends IEntity> entities, boolean sort)
This method sorts the specified entities by their y-coordinate unless the sort
parameter is set to false.
g
- The graphics object to render on.entities
- The entities to be rendered.sort
- Defines whether the entities should be sorted by the EntityYComparator
to simulate 2.5D graphics.EntityYComparator
public void renderEntity(java.awt.Graphics2D g, IEntity entity)
This method uses the IEntityAnimationController
to render the appropriate Animation
.
If the entity implements the IRenderable
interface, its render method is being called afterwards.
To listen to events about this process, you can add a EntityRenderListener
or EntityRenderedListener
to the render
engine.
g
- The graphics object to render on.entity
- The entity to be rendered.IEntity.animations()
,
IAnimationController.getCurrentImage()
,
IRenderable.render(Graphics2D)
,
canRender(IEntity)
,
EntityRenderListener.canRender(IEntity)
,
EntityRenderedListener.rendered(EntityRenderEvent)
public boolean canRender(IEntity entity)
EntityRenderListeners
.
If the RenderType
of the specified entity is set to NONE
or there are any callbacks that prevent the entity from being
rendered, this method will return false.
entity
- The entity to check whether it can be rendered or not.IEntity.getRenderType()
,
RenderType.NONE
,
EntityRenderListener.canRender(IEntity)