Package ch.epfl.cs107.play.engine.actor
Class Animation
java.lang.Object
ch.epfl.cs107.play.engine.actor.Animation
Animation is a Frames sequence of Sprite
-
Constructor Summary
ConstructorsConstructorDescriptionRepeated animation constructorDefault Animation ConstructorAnimation(String name, int nbFrames, float width, float height, Positionable parent, int regionWidth, int regionHeight, int frameDuration, boolean repeat) Animation(String name, int nbFrames, float width, float height, Positionable parent, int regionWidth, int regionHeight, Vector anchor, int frameDuration, boolean repeat) -
Method Summary
Modifier and TypeMethodDescriptionstatic Animation[]createAnimations(int animationDuration, Sprite[][] sprites) Creates an array of 4 animations (one animation per orientation) the entry indexed by Orientation.dir.ordinal() is the animation corresponding to the orientation Orientation.dir.static Animation[]createAnimations(int animationDuration, Sprite[][] sprites, boolean repeat) Creates an array of 4 animations (one animation per orientation) the entry indexed by Orientation.dir.ordinal() is the animation corresponding to the orientation Orientation.dirvoidRenders itself on specified canvas.boolean???voidreset()Reset this animation by setting the current frame to the first of the sequencevoid???voidsetHeight(float height) voidsetSpeedFactor(int SPEED_FACTOR) Update the speed factor of this Animation.voidsetWidth(float width) ???voidvoidupdate(float deltaTime) Simulates a single time step.
-
Constructor Details
-
Animation
public Animation(String name, int nbFrames, float width, float height, Positionable parent, int regionWidth, int regionHeight, Vector anchor, int frameDuration, boolean repeat) -
Animation
public Animation(String name, int nbFrames, float width, float height, Positionable parent, int regionWidth, int regionHeight, int frameDuration, boolean repeat) -
Animation
Default Animation Constructor- Parameters:
frameDuration- (int): Duration of each frame (all frames have same duration)sprites- (Sprite...): Array of sprite in the correct sequence order. Not nullrepeat- (boolean): if the animation should be repeated after it is completed
-
Animation
Repeated animation constructor- Parameters:
frameDuration- (int): Duration of each frame (all frames have same duration)sprites- (Sprite...): Array of sprite in the correct sequence order. Not null
-
-
Method Details
-
createAnimations
public static Animation[] createAnimations(int animationDuration, Sprite[][] sprites, boolean repeat) Creates an array of 4 animations (one animation per orientation) the entry indexed by Orientation.dir.ordinal() is the animation corresponding to the orientation Orientation.dir- Parameters:
animationDuration- (int): the animation durationsprites- (Sprite[][]): sprites to be played by each animation sprites[Orientation.dir.ordinal()] is the set of sprites to be played by the animation indexed by Orientation.dir.ordinal()repeat- (boolean) : true if the animations must be repeated- Returns:
- an array of 4 animations (one animation per orientation)
-
createAnimations
Creates an array of 4 animations (one animation per orientation) the entry indexed by Orientation.dir.ordinal() is the animation corresponding to the orientation Orientation.dir. The animations are repeated by default.- Parameters:
animationDuration- (int): the animation durationsprites- (Sprite[][]): sprites to be played by each animation sprites[Orientation.dir.ordinal()] is the set of sprites to be played by the animation indexed by Orientation.dir.ordinal()- Returns:
- an array of 4 animations (one animation per orientation)
-
setSpeedFactor
public void setSpeedFactor(int SPEED_FACTOR) Update the speed factor of this Animation. Can be done on the fly. Note the speed factor is given between 1 (original speed) and frameDuration (maximal speed) Hence we cannot slow down the animation !- Parameters:
SPEED_FACTOR- (int): new speed factor. Will be cropped between 1 and frameDuration
-
isCompleted
public boolean isCompleted()???- Returns:
- ???
-
setAnchor
???- Parameters:
anchor- ???
-
setWidth
public void setWidth(float width) ???- Parameters:
width- ???
-
setHeight
public void setHeight(float height) -
reset
public void reset()Reset this animation by setting the current frame to the first of the sequence -
switchPause
public void switchPause() -
update
public void update(float deltaTime) Description copied from interface:UpdatableSimulates a single time step. Note: Need to be Override -
draw
Description copied from interface:GraphicsRenders itself on specified canvas.
-