Class AnimatedGlidingSprite
java.lang.Object
com.badlogic.gdx.graphics.g2d.TextureRegion
com.github.yellowstonegames.smooth.ParentSprite
com.github.yellowstonegames.smooth.AnimatedGlidingSprite
Extends
You probably want to use Textures with a width and height of 1 world unit in your Animation, and
Sprite, but uses an Animation of TextureRegion for its visuals and a
CoordGlider to store its position. The CoordGlider is publicly available as location or with
getLocation(), which should be used to determine or change where this started its move, where it is going,
and how far it has gone between the two. You Must Call animate(float) with an increasing float parameter
when you want the animation to be playing; otherwise it will stay on the first frame (or a later frame if you stop
calling animate() at some other point). You can use the VectorSequenceGlider smallMotion to move
this Sprite at a finer resolution than between Coords for start and end points.
You probably want to use Textures with a width and height of 1 world unit in your Animation, and
ParentSprite.setSize(float, float) on this to 1, 1; this avoids the need to convert between
Coord units in the CoordGlider and some other unit in the world.-
Field Summary
FieldsModifier and TypeFieldDescriptioncom.badlogic.gdx.graphics.g2d.Animation<? extends com.badlogic.gdx.graphics.g2d.TextureRegion> final VectorSequenceGliderA VectorSequenceGlider that is empty (has no motions) and belongs to this AnimatedGlidingSprite. -
Constructor Summary
ConstructorsConstructorDescriptionAnimatedGlidingSprite(com.badlogic.gdx.graphics.g2d.Animation<? extends com.badlogic.gdx.graphics.g2d.TextureRegion> animation) AnimatedGlidingSprite(com.badlogic.gdx.graphics.g2d.Animation<? extends com.badlogic.gdx.graphics.g2d.TextureRegion> animation, com.github.yellowstonegames.grid.Coord coord) AnimatedGlidingSprite(com.badlogic.gdx.graphics.g2d.Animation<? extends com.badlogic.gdx.graphics.g2d.TextureRegion> animation, com.github.yellowstonegames.grid.Coord start, com.github.yellowstonegames.grid.Coord end) -
Method Summary
Modifier and TypeMethodDescriptionanimate(float stateTime) Required to use to have the animation play; give this a steadily increasing stateTime (measured in seconds, as a float) and it will steadily play the animation; if stateTime stops increasing or this stops being called, then the animation is effectively paused.com.badlogic.gdx.graphics.g2d.Animation<? extends com.badlogic.gdx.graphics.g2d.TextureRegion> float[]Returns the packed vertices, colors, and texture coordinates for this sprite.floatgetX()floatgetY()voidsetAnimation(com.badlogic.gdx.graphics.g2d.Animation<? extends com.badlogic.gdx.graphics.g2d.TextureRegion> animation) voidsetLocation(CoordGlider location) voidsetSmallMotion(VectorSequenceGlider smallMotion) Methods inherited from class ParentSprite
draw, draw, flip, getBoundingRectangle, getColor, getHeight, getOriginX, getOriginY, getRotation, getScaleX, getScaleY, getWidth, rotate, rotate90, scale, scroll, set, setAlpha, setBounds, setCenter, setCenterX, setCenterY, setColor, setColor, setFlip, setOrigin, setOriginBasedPosition, setOriginCenter, setPackedColor, setPosition, setRegion, setRotation, setScale, setScale, setSize, setU, setU2, setV, setV2, setX, setY, translate, translateX, translateYMethods inherited from class com.badlogic.gdx.graphics.g2d.TextureRegion
getRegionHeight, getRegionWidth, getRegionX, getRegionY, getTexture, getU, getU2, getV, getV2, isFlipX, isFlipY, setRegion, setRegion, setRegion, setRegion, setRegionHeight, setRegionWidth, setRegionX, setRegionY, setTexture, split, split
-
Field Details
-
animation
public com.badlogic.gdx.graphics.g2d.Animation<? extends com.badlogic.gdx.graphics.g2d.TextureRegion> animation -
location
-
smallMotion
-
ownEmptyMotion
A VectorSequenceGlider that is empty (has no motions) and belongs to this AnimatedGlidingSprite. This is public so external code can use it, but should never be modified. It is here sosmallMotioncan be easily set to an empty sequence. You can also usesetSmallMotion(null)to stop any small motion.
-
-
Constructor Details
-
AnimatedGlidingSprite
public AnimatedGlidingSprite(com.badlogic.gdx.graphics.g2d.Animation<? extends com.badlogic.gdx.graphics.g2d.TextureRegion> animation) -
AnimatedGlidingSprite
public AnimatedGlidingSprite(com.badlogic.gdx.graphics.g2d.Animation<? extends com.badlogic.gdx.graphics.g2d.TextureRegion> animation, com.github.yellowstonegames.grid.Coord coord) -
AnimatedGlidingSprite
public AnimatedGlidingSprite(com.badlogic.gdx.graphics.g2d.Animation<? extends com.badlogic.gdx.graphics.g2d.TextureRegion> animation, com.github.yellowstonegames.grid.Coord start, com.github.yellowstonegames.grid.Coord end)
-
-
Method Details
-
animate
Required to use to have the animation play; give this a steadily increasing stateTime (measured in seconds, as a float) and it will steadily play the animation; if stateTime stops increasing or this stops being called, then the animation is effectively paused.- Parameters:
stateTime- time playing the animation, in seconds; usually not an exact integer- Returns:
- this for chaining
-
getX
public float getX()- Overrides:
getXin classParentSprite
-
getY
public float getY()- Overrides:
getYin classParentSprite
-
getVertices
public float[] getVertices()Description copied from class:ParentSpriteReturns the packed vertices, colors, and texture coordinates for this sprite.- Overrides:
getVerticesin classParentSprite
-
getAnimation
public com.badlogic.gdx.graphics.g2d.Animation<? extends com.badlogic.gdx.graphics.g2d.TextureRegion> getAnimation() -
setAnimation
public void setAnimation(com.badlogic.gdx.graphics.g2d.Animation<? extends com.badlogic.gdx.graphics.g2d.TextureRegion> animation) -
getLocation
-
setLocation
-
getSmallMotion
-
setSmallMotion
-