public class SpriteAnimation extends Entity<T>
SpriteAnimation
is a graphical entity which displays a sequence of images. You can use this class to animate a sprite based on
milliseconds, rather than frame time.Modifier and Type | Class and Description |
---|---|
static class |
TextureBasedEntity.BlendMode
The list of supported PIXI blend modes and their associated constant.
|
Modifier and Type | Method and Description |
---|---|
double |
getAnchorX()
Returns the X anchor of this
TextureBasedEntity as a percentage of its width. |
double |
getAnchorY()
Returns the Y anchor of this
TextureBasedEntity as a percentage of its width. |
TextureBasedEntity.BlendMode |
getBlendMode()
Returns the
BlendMode this TextureBasedEntity is to be drawn with. |
int |
getDuration()
Returns the duration of the animation in milliseconds.
|
java.lang.String[] |
getImages()
Returns the names of the images used for this animation.
|
int |
getTint()
Returns the tint of this
TextureBasedEntity as an RGB integer. |
boolean |
isLoop()
Returns whether the animation should loop.
|
boolean |
isStarted()
Returns whether the animation is flagged to have the graphical counterpart start animating if it hasn't yet.
|
T |
setAnchor(double anchor)
Sets both the X and Y anchors of this
TextureBasedEntity as a percentage of its width and height. |
T |
setAnchorX(double anchorX)
Sets the X anchor of this
TextureBasedEntity as a percentage of its width. |
T |
setAnchorX(double anchorX,
Curve curve)
Sets the X anchor of this
TextureBasedEntity as a percentage of its width. |
T |
setAnchorY(double anchorY)
Sets the Y anchor of this
TextureBasedEntity as a percentage of its width. |
T |
setAnchorY(double anchorY,
Curve curve)
Sets the Y anchor of this
TextureBasedEntity as a percentage of its width. |
T |
setBlendMode(TextureBasedEntity.BlendMode blendMode)
Sets the blend mode for this
TextureBasedEntity . |
SpriteAnimation |
setDuration(int duration)
Sets the duration of the animation in milliseconds.
|
SpriteAnimation |
setImages(java.lang.String... images)
Sets the sequence of images for this animation.
|
SpriteAnimation |
setLoop(boolean loop)
Sets whether the animation loops.
|
SpriteAnimation |
setStarted(boolean started)
Begins or restarts the animation, it will always begin at the first image.
|
T |
setTint(int color)
Sets the tint of this
TextureBasedEntity as an RGB integer. |
T |
setTint(int color,
Curve curve)
Sets the tint of this
TextureBasedEntity as an RGB integer. |
void |
start()
Calls setStarted(true);
|
void |
stop()
Calls setStarted(false);
|
getAlpha, getId, getRotation, getScaleX, getScaleY, getX, getY, getZIndex, isVisible, setAlpha, setAlpha, setRotation, setRotation, setScale, setScale, setScaleX, setScaleX, setScaleY, setScaleY, setVisible, setX, setX, setY, setY, setZIndex
public boolean isStarted()
Default is false.
public SpriteAnimation setStarted(boolean started)
Setting this to false will stop the animation, but it may not be resumed without restarting.
started
- true to begin or restart animation, false to stop animationpublic void start()
public void stop()
public boolean isLoop()
Default is false.
public SpriteAnimation setLoop(boolean loop)
loop
- true to make this animation loop.public int getDuration()
Default is 1000.
public SpriteAnimation setDuration(int duration)
duration
- the duration of the animation in milliseconds.java.lang.IllegalArgumentException
- if duration is negative.public SpriteAnimation setImages(java.lang.String... images)
images
- the names of the images to use for this animation.java.lang.IllegalArgumentException
- if images is empty.public java.lang.String[] getImages()
public TextureBasedEntity.BlendMode getBlendMode()
BlendMode
this TextureBasedEntity
is to be drawn with.BlendMode
this TextureBasedEntity
is to be drawn with.public T setBlendMode(TextureBasedEntity.BlendMode blendMode)
TextureBasedEntity
.
The possible values are found in BlendMode
.
blendMode
- TextureBasedEntity
.public T setAnchor(double anchor)
TextureBasedEntity
as a percentage of its width and height.
The point calculated by the anchors times the size of this TextureBasedEntity
will be the origin for any rotation or scale.
anchor
- the percentage for both anchors of this TextureBasedEntity
.TextureBasedEntity
.public double getAnchorX()
TextureBasedEntity
as a percentage of its width.
Default is 0.
TextureBasedEntity
as a percentage of its width.public T setAnchorX(double anchorX)
TextureBasedEntity
as a percentage of its width.
The point calculated by the anchors times the size of this TextureBasedEntity
will be the origin for any rotation or scale.
anchorX
- the X anchor for this TextureBasedEntity
.TextureBasedEntity
.public T setAnchorX(double anchorX, Curve curve)
TextureBasedEntity
as a percentage of its width.
The point calculated by the anchors times the size of this TextureBasedEntity
will be the origin for any rotation or scale.
anchorX
- the X anchor for this TextureBasedEntity
.curve
- the transition to animate between values of this property.TextureBasedEntity
.public double getAnchorY()
TextureBasedEntity
as a percentage of its width.
Default is 0.
TextureBasedEntity
as a percentage of its width.public T setAnchorY(double anchorY)
TextureBasedEntity
as a percentage of its width.
The point calculated by the anchors times the size of this TextureBasedEntity
will be the origin for any rotation or scale.
anchorY
- the Y anchor for this TextureBasedEntity
.TextureBasedEntity
.public T setAnchorY(double anchorY, Curve curve)
TextureBasedEntity
as a percentage of its width.
The point calculated by the anchors times the size of this TextureBasedEntity
will be the origin for any rotation or scale.
anchorY
- the Y anchor for this TextureBasedEntity
.curve
- the transition to animate between values of this property.TextureBasedEntity
.public T setTint(int color)
TextureBasedEntity
as an RGB integer.color
- the tint of this TextureBasedEntity
.TextureBasedEntity
.java.lang.IllegalArgumentException
- if color is not a valid RGB integer.public T setTint(int color, Curve curve)
TextureBasedEntity
as an RGB integer.color
- the tint of this TextureBasedEntity
.curve
- the transition to animate between values of this property.TextureBasedEntity
.java.lang.IllegalArgumentException
- if color is not a valid RGB integer.public int getTint()
TextureBasedEntity
as an RGB integer.
Default is 0xFFFFFF (white)
TextureBasedEntity
.