Search in sources :

Example 6 with Animator

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

the class UtilAttackable method prepare.

/**
 * Create the featurable.
 *
 * @param featurable The featurable to prepare.
 */
public static void prepare(Featurable featurable) {
    final Animator animator = new AnimatorMock();
    animator.play(new Animation("test", 1, 1, 1.0, false, false));
    featurable.addFeature(new AnimatableModel(animator));
    featurable.addFeature(new TransformableModel());
}
Also used : Animator(com.b3dgs.lionengine.Animator) AnimatableModel(com.b3dgs.lionengine.game.feature.AnimatableModel) TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) Animation(com.b3dgs.lionengine.Animation) AnimatorMock(com.b3dgs.lionengine.core.drawable.AnimatorMock)

Example 7 with Animator

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

the class AnimatorTest method testSetSpeedNegative.

/**
 * Test invalid speed setter.
 */
@Test(expected = LionEngineException.class)
public void testSetSpeedNegative() {
    final Animator animator = new AnimatorImpl();
    animator.setAnimSpeed(-1.0);
}
Also used : Animator(com.b3dgs.lionengine.Animator) Test(org.junit.Test)

Example 8 with Animator

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

the class AnimatorTest method testPlayNull.

/**
 * Test play with <code>null</code> argument.
 */
@Test(expected = LionEngineException.class)
public void testPlayNull() {
    final Animator animator = new AnimatorImpl();
    animator.play(null);
}
Also used : Animator(com.b3dgs.lionengine.Animator) Test(org.junit.Test)

Example 9 with Animator

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

the class AnimatorTest method testStop.

/**
 * Test stop.
 */
@Test
public void testStop() {
    final Animator animator = new AnimatorImpl();
    animator.stop();
    Assert.assertEquals(AnimState.STOPPED, animator.getAnimState());
}
Also used : Animator(com.b3dgs.lionengine.Animator) Test(org.junit.Test)

Example 10 with Animator

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

the class AnimatorTest method testUpdateLoopReverse.

/**
 * Test update with loop and reverse.
 */
@Test
public void testUpdateLoopReverse() {
    final Animation animation = new Animation(Animation.DEFAULT_NAME, 1, 3, 1.0, true, 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.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.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());
}
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