public class GraphicEntityModule extends Object implements Module
The GraphicEntityModule takes care of displaying and animating graphical entities on the replay of the game.
Use it by creating shapes, sprites, texts etc, then committing their states to a certain moment of the frame. By default, the states are commited automatically at the end of the frame.Modifier and Type | Method and Description |
---|---|
void |
commitEntityState(double t,
Entity<?>... entities)
This entity's graphical counterpart, at instant t of the frame being computed, will have the same properties as the java object as it is now.
|
void |
commitWorldState(double t)
Creates a commit for each entity that has had some of its properties modified since a previous commit or the previous frame.
|
BitmapText |
createBitmapText()
Creates a new BitmapText entity, its graphical counterpart will be created on the frame currently being computed.
|
BufferedGroup |
createBufferedGroup(Entity<?>... entities)
Creates a new BufferedGroup entity, its graphical counterpart will be created on the frame currently being computed.
|
Circle |
createCircle()
Creates a new Circle entity, its graphical counterpart will be created on the frame currently being computed.
|
Group |
createGroup(Entity<?>... entities)
Creates a new Group entity, its graphical counterpart will be created on the frame currently being computed.
|
Line |
createLine()
Creates a new Line entity, its graphical counterpart will be created on the frame currently being computed.
|
Polygon |
createPolygon()
Creates a new Polygon entity, its graphical counterpart will be created on the frame currently being computed.
|
Rectangle |
createRectangle()
Creates a new Rectangle entity, its graphical counterpart will be created on the frame currently being computed.
|
RoundedRectangle |
createRoundedRectangle()
Creates a new RoundedRectangle entity, its graphical counterpart will be created on the frame currently being computed.
|
Sprite |
createSprite()
Creates a new Sprite entity, its graphical counterpart will be created on the frame currently being computed.
|
SpriteAnimation |
createSpriteAnimation()
Creates a new Sprite animation, its graphical counterpart will be created on the frame currently being computed.
|
SpriteSheetSplitter |
createSpriteSheetSplitter()
Create a spritesheet splitter.
|
Text |
createText()
Creates a new Text entity, its graphical counterpart will be created on the frame currently being computed.
|
Text |
createText(String string)
Creates a new Text entity, its graphical counterpart will be created on the frame currently being computed.
|
TilingSprite |
createTilingSprite()
Creates a new TilingSprite entity, its graphical counterpart will be created on the frame currently being computed.
|
World |
createWorld(int width,
int height)
Creates a new world data object to be used to compute all frames throughout the game.
|
World |
getWorld() |
void |
onAfterGameTurn()
Called by the game manager after calling the
Referee 's gameTurn method. |
void |
onAfterOnEnd()
Called by the game manager after calling the
Referee 's onEnd method. |
void |
onGameInit()
Called by the game manager after calling the
Referee 's init method. |
public World createWorld(int width, int height)
This method may only be called once. This method may not be called after the frames have started being computed.
The world's width and height determine how the positions of all entities are mapped onto the viewer.
width
- The number of units across the width of the visible part of the game. Default is 1920.height
- The number of units across the height of the visible part of the game. Default is 1080.IllegalStateException
- if the method is called more than once or after the game begins.public World getWorld()
public SpriteSheetSplitter createSpriteSheetSplitter()
public void commitWorldState(double t)
Creates a commit for each entity that has had some of its properties modified since a previous commit or the previous frame.
This means that each one of those entities' graphical counterparts, at instant t of the frame being computed, will have the same properties as the java object as they are now.
To force an entity to keep its current state instead of interpolating to the values of next frame, use commitEntityState
instead.
Only the most recent commits are kept for a given t.
t
- The instant of the frame 0 ≤ t ≤ 1.IllegalArgumentException
- if the t is not a valid instant.public void commitEntityState(double t, Entity<?>... entities)
Only the most recent commit is kept for a given t.
t
- The instant of the frame 0 ≤ t ≤ 1.entities
- The entity objects to commit.IllegalArgumentException
- if the t is not a valid instant or id entities is empty.public Circle createCircle()
public Sprite createSprite()
public Line createLine()
public Rectangle createRectangle()
public RoundedRectangle createRoundedRectangle()
public Polygon createPolygon()
public Text createText(String string)
string
- The default string for the text. Can be changed.public Text createText()
public BitmapText createBitmapText()
public Group createGroup(Entity<?>... entities)
A Group represents a collection of other entities. It acts as a container.
entities
- 0 or more entities to immediately add to this group.public BufferedGroup createBufferedGroup(Entity<?>... entities)
A BufferedGroup acts like a group but uses its own rendering system to avoid rounding errors when its children are scaled up or down.
entities
- 0 or more entities to immediately add to this group.public SpriteAnimation createSpriteAnimation()
public TilingSprite createTilingSprite()
public final void onGameInit()
Module
Referee
's init method.
The module must be registered to the game manager.onGameInit
in interface Module
public final void onAfterGameTurn()
Module
Referee
's gameTurn method.
The module must be registered to the game manager.onAfterGameTurn
in interface Module
public final void onAfterOnEnd()
Module
Referee
's onEnd method.
The module must be registered to the game manager.onAfterOnEnd
in interface Module
Copyright © 2024. All rights reserved.