Class Entity<T extends Entity<?>>
- Type Parameters:
T- a subclass inheriting Entity, used in order to return this as a T instead of an Entity.
- Direct Known Subclasses:
BlendableEntity,ContainerBasedEntity
A graphical entity, displayed on screen in the game's replay.
The graphical counterpart's coordinates are converted from world units to pixel coordinates.-
Method Summary
Modifier and TypeMethodDescriptiondoublegetAlpha()Returns the alpha of thisEntityas a percentage.intgetId()Returns a unique identifier for thisEntity.getMask()Returns thisEntity'sMask.doubleReturns the rotation of thisEntityin radians.doubleReturns the horizontal scale of thisEntityas a percentage.doubleReturns the vertical scale of thisEntityas a percentage.doublegetSkewX()Returns the horizontal skew of thisEntityin radians.doublegetSkewY()Returns the vertical skew of thisEntityin radians.intgetX()Returns the X coordinate of thisEntityin world units.intgetY()Returns the Y coordinate of thisEntityin world units.intReturns the z-index of thisEntityused to compute the display order for overlapping entities.booleanReturns whether thisEntityis flagged to be drawn on screen.protected static voidrequireValidAlpha(double alpha) protected static voidrequireValidColor(int color) protected Tself()protected voidprotected voidsetAlpha(double alpha) Sets the alpha of thisEntityas a percentage.Sets the alpha of thisEntityas a percentage.Sets a givenMaskas thisEntity'sMask.setMask(SpriteAnimation animation) Sets a givenSpriteAnimationas thisEntity'sMask.setRotation(double rotation) Sets the rotation of thisEntityin radians.setRotation(double rotation, Curve curve) Sets the rotation of thisEntityin radians.setScale(double scale) Sets both the horizontal and vertical scale of thisEntityto the same percentage.Sets both the horizontal and vertical scale of thisEntityto the same percentage.setScaleX(double scaleX) Sets the horizontal scale of thisEntityas a percentage.Sets the horizontal scale of thisEntityas a percentage.setScaleY(double scaleY) Sets the vertical scale of thisEntityas a percentage.Sets the vertical scale of thisEntityas a percentage.setSkewX(double skewX) Sets the horizontal skew of thisEntityin radians.Sets the horizontal skew of thisEntityin radians.setSkewY(double skewY) Sets the vertical skew of thisEntityin radians.Sets the vertical skew of thisEntityin radians.setVisible(boolean visible) Flags thisEntityto be drawn on screen or not.setX(int x) Sets the X coordinate of thisEntityin world units.Sets the X coordinate of thisEntityin world units.setY(int y) Sets the Y coordinate of thisEntityin world units.Sets the Y coordinate of thisEntityin world units.setZIndex(int zIndex) Sets the z-index of thisEntityused to compute the display order for overlapping entities.
-
Method Details
-
self
-
getId
public int getId()Returns a unique identifier for thisEntity.- Returns:
- A unique identifier.
-
set
-
set
-
setX
Sets the X coordinate of thisEntityin world units.Default is 0.
- Parameters:
x- the X coordinate for thisEntity.- Returns:
- this
Entity.
-
setX
Sets the X coordinate of thisEntityin world units.Default is 0.
- Parameters:
x- the X coordinate for thisEntity.curve- the transition to animate between values of this property.- Returns:
- this
Entity.
-
setY
Sets the Y coordinate of thisEntityin world units.Default is 0.
- Parameters:
y- the Y coordinate for thisEntity.- Returns:
- this
Entity.
-
setY
Sets the Y coordinate of thisEntityin world units.Default is 0.
- Parameters:
y- the Y coordinate for thisEntity.curve- the transition to animate between values of this property.- Returns:
- this
Entity.
-
setZIndex
Sets the z-index of this
Entityused to compute the display order for overlapping entities.An
In case of equal values, the most recently createdEntitywith a higher z-index is displayed over one with a smaller z-index.Entitywill be on top.Default is 0.
- Parameters:
zIndex- the z-index for thisEntity.- Returns:
- this
Entity.
-
setScaleX
Sets the horizontal scale of thisEntityas a percentage.Default is 1.
- Parameters:
scaleX- the horizontal scale for thisEntity.- Returns:
- this
Entity.
-
setScaleX
Sets the horizontal scale of thisEntityas a percentage.Default is 1.
- Parameters:
scaleX- the horizontal scale for thisEntity.curve- the transition to animate between values of this property.- Returns:
- this
Entity.
-
setScaleY
Sets the vertical scale of thisEntityas a percentage.Default is 1.
- Parameters:
scaleY- the vertical scale for thisEntity.- Returns:
- this
Entity.
-
setScaleY
Sets the vertical scale of thisEntityas a percentage.Default is 1.
- Parameters:
scaleY- the vertical scale for thisEntity.curve- the transition to animate between values of this property.- Returns:
- this
Entity.
-
setSkewX
Sets the horizontal skew of thisEntityin radians.Default is 0.
- Parameters:
skewX- the horizontal skew for thisEntity.- Returns:
- this
Entity.
-
setSkewX
Sets the horizontal skew of thisEntityin radians.Default is 0.
- Parameters:
skewX- the horizontal skew for thisEntity.curve- the transition to animate between values of this property.- Returns:
- this
Entity.
-
setSkewY
Sets the vertical skew of thisEntityin radians.Default is 0.
- Parameters:
skewY- the vertical skew for thisEntity.- Returns:
- this
Entity.
-
setSkewY
Sets the vertical skew of thisEntityin radians.Default is 0.
- Parameters:
skewY- the vertical skew for thisEntity.curve- the transition to animate between values of this property.- Returns:
- this
Entity.
-
setAlpha
Sets the alpha of this
1 is opaque and 0 is invisible.Entityas a percentage.Default is 1.
- Parameters:
alpha- the alpha for thisEntity.- Returns:
- this
Entity. - Throws:
IllegalArgumentException- if alpha < 0 or alpha > 1
-
setAlpha
Sets the alpha of this
1 is opaque and 0 is invisible.Entityas a percentage.Default is 1.
- Parameters:
alpha- the alpha for thisEntity.curve- the transition to animate between values of this property.- Returns:
- this
Entity. - Throws:
IllegalArgumentException- if alpha < 0 or alpha > 1
-
setScale
Sets both the horizontal and vertical scale of thisEntityto the same percentage.- Parameters:
scale- the scale for thisEntity.- Returns:
- this
Entity.
-
setScale
Sets both the horizontal and vertical scale of thisEntityto the same percentage.- Parameters:
scale- the scale for thisEntity.curve- the transition to animate between values of this property.- Returns:
- this
Entity.
-
setRotation
Sets the rotation of thisEntityin radians.Default is 0.
- Parameters:
rotation- the rotation for thisEntity.- Returns:
- this
Entity.
-
setRotation
Sets the rotation of thisEntityin radians.Default is 0.
- Parameters:
rotation- the rotation for thisEntity.curve- the transition to animate between values of this property.- Returns:
- this
Entity.
-
setVisible
Flags thisEntityto be drawn on screen or not.Default is true.
- Parameters:
visible- the value for thisEntity's visible flag.- Returns:
- this
Entity.
-
getX
public int getX()Returns the X coordinate of thisEntityin world units.- Returns:
- the X coordinate of this
Entity.
-
getY
public int getY()Returns the Y coordinate of thisEntityin world units.- Returns:
- the Y coordinate of this
Entity.
-
getZIndex
public int getZIndex()Returns the z-index of thisEntityused to compute the display order for overlapping entities.- Returns:
- the z-index of this
Entity.
-
getScaleX
public double getScaleX()Returns the horizontal scale of thisEntityas a percentage.Default is 1.
- Returns:
- the horizontal scale of this
Entity.
-
getScaleY
public double getScaleY()Returns the vertical scale of thisEntityas a percentage.Default is 1.
- Returns:
- the vertical scale of this
Entity.
-
getSkewX
public double getSkewX()Returns the horizontal skew of thisEntityin radians.Default is 0.
- Returns:
- the horizontal skew of this
Entity.
-
getSkewY
public double getSkewY()Returns the vertical skew of thisEntityin radians.Default is 0.
- Returns:
- the vertical skew of this
Entity.
-
getAlpha
public double getAlpha()Returns the alpha of thisEntityas a percentage.Default is 1.
- Returns:
- the alpha of this
Entity.
-
getRotation
public double getRotation()Returns the rotation of thisEntityin radians.Default is 0.
- Returns:
- the rotation coordinate of this
Entity.
-
isVisible
public boolean isVisible()Returns whether thisEntityis flagged to be drawn on screen.Default is true.
- Returns:
- the value of the visible flag of this
Entity.
-
setMask
Sets a given
Note: texture masks will only work on browsers which support WebGLMaskas thisEntity'sMask.- Parameters:
mask- the mask.- Returns:
- this
Entity.
-
setMask
Sets a given
Note: texture masks will only work on browsers which support WebGLSpriteAnimationas thisEntity'sMask.- Parameters:
animation- the mask.- Returns:
- this
Entity.
-
getMask
Returns this
AEntity'sMask.Maskcan be:- a
Shape - a
Sprite - a
SpriteAnimation
Default is null.
- Returns:
- this
Entity'sMask.
- a
-
requireValidAlpha
protected static void requireValidAlpha(double alpha) -
requireValidColor
protected static void requireValidColor(int color) -
getParent
- Returns:
- the Group or BufferedGroup which contains this entity
-