use of com.b3dgs.lionengine.Animation in project lionengine by b3dgs.
the class AnimatorTest method testSetFrame.
/**
* Test set frame.
*/
@Test
public void testSetFrame() {
final Animation animation = new Animation(Animation.DEFAULT_NAME, 1, 3, 1.0, false, false);
final Animator animator = new AnimatorImpl();
animator.play(animation);
animator.setFrame(2);
animator.update(1.0);
Assert.assertEquals(AnimState.PLAYING, animator.getAnimState());
Assert.assertEquals(3, animator.getFrame());
Assert.assertEquals(3, animator.getFrameAnim());
}
use of com.b3dgs.lionengine.Animation in project lionengine by b3dgs.
the class AnimatorTest method testPlay.
/**
* Test play.
*/
@Test
public void testPlay() {
final Animation animation = new Animation(Animation.DEFAULT_NAME, 1, 2, 3.0, false, false);
final Animator animator = new AnimatorImpl();
animator.play(animation);
Assert.assertEquals(AnimState.PLAYING, animator.getAnimState());
Assert.assertEquals(1, animator.getFrame());
Assert.assertEquals(1, animator.getFrameAnim());
}
use of com.b3dgs.lionengine.Animation in project lionengine by b3dgs.
the class AnimatorTest method testUpdateNoLoopReverse.
/**
* Test update without loop but reverse.
*/
@Test
public void testUpdateNoLoopReverse() {
final Animation animation = new Animation(Animation.DEFAULT_NAME, 1, 3, 1.0, true, false);
final Animator animator = new AnimatorImpl();
animator.play(animation);
Assert.assertEquals(AnimState.PLAYING, animator.getAnimState());
Assert.assertEquals(1, animator.getFrame());
Assert.assertEquals(1, animator.getFrameAnim());
animator.update(1.0);
Assert.assertEquals(AnimState.PLAYING, animator.getAnimState());
Assert.assertEquals(2, animator.getFrame());
Assert.assertEquals(2, animator.getFrameAnim());
animator.update(1.0);
Assert.assertEquals(AnimState.PLAYING, animator.getAnimState());
Assert.assertEquals(3, animator.getFrame());
Assert.assertEquals(3, animator.getFrameAnim());
animator.update(1.0);
Assert.assertEquals(AnimState.REVERSING, animator.getAnimState());
Assert.assertEquals(2, animator.getFrame());
Assert.assertEquals(2, animator.getFrameAnim());
animator.update(1.0);
Assert.assertEquals(AnimState.REVERSING, animator.getAnimState());
Assert.assertEquals(1, animator.getFrame());
Assert.assertEquals(1, animator.getFrameAnim());
animator.update(1.0);
Assert.assertEquals(AnimState.FINISHED, animator.getAnimState());
Assert.assertEquals(1, animator.getFrame());
Assert.assertEquals(1, animator.getFrameAnim());
}
use of com.b3dgs.lionengine.Animation in project lionengine by b3dgs.
the class SpriteAnimatedTest method testUpdateLoopNoReverse.
/**
* Test update with loop but no reverse.
*/
@Test
public void testUpdateLoopNoReverse() {
final Animation animation = new Animation(Animation.DEFAULT_NAME, 1, 3, 1.0, false, true);
final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
sprite.play(animation);
Assert.assertEquals(AnimState.PLAYING, sprite.getAnimState());
Assert.assertEquals(1, sprite.getFrame());
Assert.assertEquals(1, sprite.getFrameAnim());
sprite.update(1.0);
Assert.assertEquals(AnimState.PLAYING, sprite.getAnimState());
Assert.assertEquals(2, sprite.getFrame());
Assert.assertEquals(2, sprite.getFrameAnim());
sprite.update(1.0);
Assert.assertEquals(AnimState.PLAYING, sprite.getAnimState());
Assert.assertEquals(3, sprite.getFrame());
Assert.assertEquals(3, sprite.getFrameAnim());
sprite.update(1.0);
Assert.assertEquals(AnimState.PLAYING, sprite.getAnimState());
Assert.assertEquals(1, sprite.getFrame());
Assert.assertEquals(1, sprite.getFrameAnim());
sprite.update(1.0);
Assert.assertEquals(AnimState.PLAYING, sprite.getAnimState());
Assert.assertEquals(2, sprite.getFrame());
Assert.assertEquals(2, sprite.getFrameAnim());
}
use of com.b3dgs.lionengine.Animation in project lionengine by b3dgs.
the class SpriteAnimatedTest method testUpdateNoLoopNoReverse.
/**
* Test update without loop nor reverse.
*/
@Test
public void testUpdateNoLoopNoReverse() {
final Animation animation = new Animation(Animation.DEFAULT_NAME, 1, 2, 1.0, false, false);
final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
sprite.play(animation);
Assert.assertEquals(AnimState.PLAYING, sprite.getAnimState());
Assert.assertEquals(1, sprite.getFrame());
Assert.assertEquals(1, sprite.getFrameAnim());
sprite.update(1.0);
Assert.assertEquals(AnimState.PLAYING, sprite.getAnimState());
Assert.assertEquals(2, sprite.getFrame());
Assert.assertEquals(2, sprite.getFrameAnim());
sprite.update(1.0);
Assert.assertEquals(AnimState.FINISHED, sprite.getAnimState());
Assert.assertEquals(2, sprite.getFrame());
Assert.assertEquals(2, sprite.getFrameAnim());
sprite.update(1.0);
Assert.assertEquals(AnimState.FINISHED, sprite.getAnimState());
Assert.assertEquals(2, sprite.getFrame());
Assert.assertEquals(2, sprite.getFrameAnim());
}
Aggregations