Search in sources :

Example 1 with Animator

use of com.b3dgs.lionengine.Animator in project lionengine by b3dgs.

the class AnimatorTest 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 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.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());
}
Also used : Animator(com.b3dgs.lionengine.Animator) Animation(com.b3dgs.lionengine.Animation) Test(org.junit.Test)

Example 2 with Animator

use of com.b3dgs.lionengine.Animator in project lionengine by b3dgs.

the class AnimatorTest method testSetSpeed.

/**
 * Test set speed.
 */
@Test
public void testSetSpeed() {
    final Animation animation = new Animation(Animation.DEFAULT_NAME, 1, 3, 1.0, false, false);
    final Animator animator = new AnimatorImpl();
    animator.play(animation);
    animator.setAnimSpeed(2.0);
    animator.update(1.0);
    Assert.assertEquals(AnimState.PLAYING, animator.getAnimState());
    Assert.assertEquals(3, animator.getFrame());
    Assert.assertEquals(3, animator.getFrameAnim());
}
Also used : Animator(com.b3dgs.lionengine.Animator) Animation(com.b3dgs.lionengine.Animation) Test(org.junit.Test)

Example 3 with Animator

use of com.b3dgs.lionengine.Animator in project lionengine by b3dgs.

the class AnimatorTest method testFrameInvalid.

/**
 * Test set frame invalid.
 */
@Test(expected = LionEngineException.class)
public void testFrameInvalid() {
    final Animator animator = new AnimatorImpl();
    animator.setFrame(0);
}
Also used : Animator(com.b3dgs.lionengine.Animator) Test(org.junit.Test)

Example 4 with Animator

use of com.b3dgs.lionengine.Animator in project lionengine by b3dgs.

the class AnimatorTest method testConstructor.

/**
 * Test constructor default.
 */
@Test
public void testConstructor() {
    final Animator animator = new AnimatorImpl();
    Assert.assertEquals(AnimState.STOPPED, animator.getAnimState());
    Assert.assertEquals(Animation.MINIMUM_FRAME, animator.getFrame());
    Assert.assertEquals(Animation.MINIMUM_FRAME, animator.getFrameAnim());
}
Also used : Animator(com.b3dgs.lionengine.Animator) Test(org.junit.Test)

Example 5 with Animator

use of com.b3dgs.lionengine.Animator in project lionengine by b3dgs.

the class AnimatorTest 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 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.FINISHED, animator.getAnimState());
    Assert.assertEquals(2, animator.getFrame());
    Assert.assertEquals(2, animator.getFrameAnim());
    animator.update(1.0);
    Assert.assertEquals(AnimState.FINISHED, animator.getAnimState());
    Assert.assertEquals(2, animator.getFrame());
    Assert.assertEquals(2, animator.getFrameAnim());
}
Also used : Animator(com.b3dgs.lionengine.Animator) Animation(com.b3dgs.lionengine.Animation) Test(org.junit.Test)

Aggregations

Animator (com.b3dgs.lionengine.Animator)14 Test (org.junit.Test)12 Animation (com.b3dgs.lionengine.Animation)9 AnimatableModel (com.b3dgs.lionengine.game.feature.AnimatableModel)2 TransformableModel (com.b3dgs.lionengine.game.feature.TransformableModel)2 AnimatorModel (com.b3dgs.lionengine.AnimatorModel)1 AnimatorMock (com.b3dgs.lionengine.core.drawable.AnimatorMock)1