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 TypeMethodDescriptiondouble
getAlpha()
Returns the alpha of thisEntity
as a percentage.int
getId()
Returns a unique identifier for thisEntity
.getMask()
Returns thisEntity
'sMask
.double
Returns the rotation of thisEntity
in radians.double
Returns the horizontal scale of thisEntity
as a percentage.double
Returns the vertical scale of thisEntity
as a percentage.double
getSkewX()
Returns the horizontal skew of thisEntity
in radians.double
getSkewY()
Returns the vertical skew of thisEntity
in radians.int
getX()
Returns the X coordinate of thisEntity
in world units.int
getY()
Returns the Y coordinate of thisEntity
in world units.int
Returns the z-index of thisEntity
used to compute the display order for overlapping entities.boolean
Returns whether thisEntity
is flagged to be drawn on screen.protected static void
requireValidAlpha
(double alpha) protected static void
requireValidColor
(int color) protected T
self()
protected void
protected void
setAlpha
(double alpha) Sets the alpha of thisEntity
as a percentage.Sets the alpha of thisEntity
as a percentage.Sets a givenMask
as thisEntity
'sMask
.setMask
(SpriteAnimation animation) Sets a givenSpriteAnimation
as thisEntity
'sMask
.setRotation
(double rotation) Sets the rotation of thisEntity
in radians.setRotation
(double rotation, Curve curve) Sets the rotation of thisEntity
in radians.setScale
(double scale) Sets both the horizontal and vertical scale of thisEntity
to the same percentage.Sets both the horizontal and vertical scale of thisEntity
to the same percentage.setScaleX
(double scaleX) Sets the horizontal scale of thisEntity
as a percentage.Sets the horizontal scale of thisEntity
as a percentage.setScaleY
(double scaleY) Sets the vertical scale of thisEntity
as a percentage.Sets the vertical scale of thisEntity
as a percentage.setSkewX
(double skewX) Sets the horizontal skew of thisEntity
in radians.Sets the horizontal skew of thisEntity
in radians.setSkewY
(double skewY) Sets the vertical skew of thisEntity
in radians.Sets the vertical skew of thisEntity
in radians.setVisible
(boolean visible) Flags thisEntity
to be drawn on screen or not.setX
(int x) Sets the X coordinate of thisEntity
in world units.Sets the X coordinate of thisEntity
in world units.setY
(int y) Sets the Y coordinate of thisEntity
in world units.Sets the Y coordinate of thisEntity
in world units.setZIndex
(int zIndex) Sets the z-index of thisEntity
used 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 thisEntity
in world units.Default is 0.
- Parameters:
x
- the X coordinate for thisEntity
.- Returns:
- this
Entity
.
-
setX
Sets the X coordinate of thisEntity
in 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 thisEntity
in world units.Default is 0.
- Parameters:
y
- the Y coordinate for thisEntity
.- Returns:
- this
Entity
.
-
setY
Sets the Y coordinate of thisEntity
in 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
Entity
used to compute the display order for overlapping entities.An
In case of equal values, the most recently createdEntity
with a higher z-index is displayed over one with a smaller z-index.Entity
will be on top.Default is 0.
- Parameters:
zIndex
- the z-index for thisEntity
.- Returns:
- this
Entity
.
-
setScaleX
Sets the horizontal scale of thisEntity
as a percentage.Default is 1.
- Parameters:
scaleX
- the horizontal scale for thisEntity
.- Returns:
- this
Entity
.
-
setScaleX
Sets the horizontal scale of thisEntity
as 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 thisEntity
as a percentage.Default is 1.
- Parameters:
scaleY
- the vertical scale for thisEntity
.- Returns:
- this
Entity
.
-
setScaleY
Sets the vertical scale of thisEntity
as 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 thisEntity
in radians.Default is 0.
- Parameters:
skewX
- the horizontal skew for thisEntity
.- Returns:
- this
Entity
.
-
setSkewX
Sets the horizontal skew of thisEntity
in 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 thisEntity
in radians.Default is 0.
- Parameters:
skewY
- the vertical skew for thisEntity
.- Returns:
- this
Entity
.
-
setSkewY
Sets the vertical skew of thisEntity
in 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.Entity
as 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.Entity
as 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 thisEntity
to the same percentage.- Parameters:
scale
- the scale for thisEntity
.- Returns:
- this
Entity
.
-
setScale
Sets both the horizontal and vertical scale of thisEntity
to 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 thisEntity
in radians.Default is 0.
- Parameters:
rotation
- the rotation for thisEntity
.- Returns:
- this
Entity
.
-
setRotation
Sets the rotation of thisEntity
in 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 thisEntity
to 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 thisEntity
in world units.- Returns:
- the X coordinate of this
Entity
.
-
getY
public int getY()Returns the Y coordinate of thisEntity
in world units.- Returns:
- the Y coordinate of this
Entity
.
-
getZIndex
public int getZIndex()Returns the z-index of thisEntity
used to compute the display order for overlapping entities.- Returns:
- the z-index of this
Entity
.
-
getScaleX
public double getScaleX()Returns the horizontal scale of thisEntity
as a percentage.Default is 1.
- Returns:
- the horizontal scale of this
Entity
.
-
getScaleY
public double getScaleY()Returns the vertical scale of thisEntity
as a percentage.Default is 1.
- Returns:
- the vertical scale of this
Entity
.
-
getSkewX
public double getSkewX()Returns the horizontal skew of thisEntity
in radians.Default is 0.
- Returns:
- the horizontal skew of this
Entity
.
-
getSkewY
public double getSkewY()Returns the vertical skew of thisEntity
in radians.Default is 0.
- Returns:
- the vertical skew of this
Entity
.
-
getAlpha
public double getAlpha()Returns the alpha of thisEntity
as a percentage.Default is 1.
- Returns:
- the alpha of this
Entity
.
-
getRotation
public double getRotation()Returns the rotation of thisEntity
in radians.Default is 0.
- Returns:
- the rotation coordinate of this
Entity
.
-
isVisible
public boolean isVisible()Returns whether thisEntity
is 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 WebGLMask
as thisEntity
'sMask
.- Parameters:
mask
- the mask.- Returns:
- this
Entity
.
-
setMask
Sets a given
Note: texture masks will only work on browsers which support WebGLSpriteAnimation
as thisEntity
'sMask
.- Parameters:
animation
- the mask.- Returns:
- this
Entity
.
-
getMask
Returns this
AEntity
'sMask
.Mask
can 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
-