Class GraphicEntityModule
- All Implemented Interfaces:
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.-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.Creates a new BitmapText entity, its graphical counterpart will be created on the frame currently being computed.createBufferedGroup
(Entity<?>... entities) Creates a new BufferedGroup entity, its graphical counterpart will be created on the frame currently being computed.Creates a new Circle entity, its graphical counterpart will be created on the frame currently being computed.createGroup
(Entity<?>... entities) Creates a new Group entity, its graphical counterpart will be created on the frame currently being computed.Creates a new Line entity, its graphical counterpart will be created on the frame currently being computed.Creates a new Polygon entity, its graphical counterpart will be created on the frame currently being computed.Creates a new Rectangle entity, its graphical counterpart will be created on the frame currently being computed.Creates a new RoundedRectangle entity, its graphical counterpart will be created on the frame currently being computed.Creates a new Sprite entity, its graphical counterpart will be created on the frame currently being computed.Creates a new Sprite animation, its graphical counterpart will be created on the frame currently being computed.Create a spritesheet splitter.Creates a new Text entity, its graphical counterpart will be created on the frame currently being computed.createText
(String string) Creates a new Text entity, its graphical counterpart will be created on the frame currently being computed.Creates a new TilingSprite entity, its graphical counterpart will be created on the frame currently being computed.createWorld
(int width, int height) Creates a new world data object to be used to compute all frames throughout the game.getWorld()
final void
Called by the game manager after calling theReferee
's gameTurn method.final void
Called by the game manager after calling theReferee
's onEnd method.final void
Called by the game manager after calling theReferee
's init method.
-
Method Details
-
createWorld
Creates a new world data object to be used to compute all frames throughout the game.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.
- Parameters:
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.- Returns:
- the world data object.
- Throws:
IllegalStateException
- if the method is called more than once or after the game begins.
-
getWorld
- Returns:
- the world data currently being used for computing frames
-
createSpriteSheetSplitter
Create a spritesheet splitter.- Returns:
- a SpriteSheetSplitter
-
commitWorldState
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.
- Parameters:
t
- The instant of the frame 0 ≤ t ≤ 1.- Throws:
IllegalArgumentException
- if the t is not a valid instant.
-
commitEntityState
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.Only the most recent commit is kept for a given t.
- Parameters:
t
- The instant of the frame 0 ≤ t ≤ 1.entities
- The entity objects to commit.- Throws:
IllegalArgumentException
- if the t is not a valid instant or id entities is empty.
-
createCircle
Creates a new Circle entity, its graphical counterpart will be created on the frame currently being computed.- Returns:
- the entity. Modify its properties to animate the graphical counterpart.
-
createSprite
Creates a new Sprite entity, its graphical counterpart will be created on the frame currently being computed.- Returns:
- the entity. Modify its properties to animate the graphical counterpart.
-
createLine
Creates a new Line entity, its graphical counterpart will be created on the frame currently being computed.- Returns:
- the entity. Modify its properties to animate the graphical counterpart.
-
createRectangle
Creates a new Rectangle entity, its graphical counterpart will be created on the frame currently being computed.- Returns:
- the entity. Modify its properties to animate the graphical counterpart.
-
createRoundedRectangle
Creates a new RoundedRectangle entity, its graphical counterpart will be created on the frame currently being computed.- Returns:
- the entity. Modify its properties to animate the graphical counterpart.
-
createPolygon
Creates a new Polygon entity, its graphical counterpart will be created on the frame currently being computed.- Returns:
- the entity. Modify its properties to animate the graphical counterpart.
-
createText
Creates a new Text entity, its graphical counterpart will be created on the frame currently being computed.- Parameters:
string
- The default string for the text. Can be changed.- Returns:
- the entity. Modify its properties to animate the graphical counterpart.
-
createText
Creates a new Text entity, its graphical counterpart will be created on the frame currently being computed.- Returns:
- the entity. Modify its properties to animate the graphical counterpart.
-
createBitmapText
Creates a new BitmapText entity, its graphical counterpart will be created on the frame currently being computed.- Returns:
- the entity. Modify its properties to animate the graphical counterpart.
-
createGroup
Creates a new Group entity, its graphical counterpart will be created on the frame currently being computed.A Group represents a collection of other entities. It acts as a container.
- Parameters:
entities
- 0 or more entities to immediately add to this group.- Returns:
- the entity. Modify its properties to animate the graphical counterpart.
-
createBufferedGroup
Creates a new BufferedGroup entity, its graphical counterpart will be created on the frame currently being computed.A BufferedGroup acts like a group but uses its own rendering system to avoid rounding errors when its children are scaled up or down.
- Parameters:
entities
- 0 or more entities to immediately add to this group.- Returns:
- the entity. Modify its properties to animate the graphical counterpart.
-
createSpriteAnimation
Creates a new Sprite animation, its graphical counterpart will be created on the frame currently being computed.- Returns:
- the entity. Modify its properties to animate the graphical counterpart.
-
createTilingSprite
Creates a new TilingSprite entity, its graphical counterpart will be created on the frame currently being computed.- Returns:
- the entity. Modify its properties to animate the graphical counterpart.
-
onGameInit
public final void onGameInit()Description copied from interface:Module
Called by the game manager after calling theReferee
's init method. The module must be registered to the game manager.- Specified by:
onGameInit
in interfaceModule
-
onAfterGameTurn
public final void onAfterGameTurn()Description copied from interface:Module
Called by the game manager after calling theReferee
's gameTurn method. The module must be registered to the game manager.- Specified by:
onAfterGameTurn
in interfaceModule
-
onAfterOnEnd
public final void onAfterOnEnd()Description copied from interface:Module
Called by the game manager after calling theReferee
's onEnd method. The module must be registered to the game manager.- Specified by:
onAfterOnEnd
in interfaceModule
-