Search in sources :

Example 31 with SpriteAnimated

use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.

the class SpriteAnimatedTest method testMirrorNull.

/**
 * Test mirror <code>null</code>.
 */
@Test(expected = LionEngineException.class)
public void testMirrorNull() {
    final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    sprite.setMirror(null);
}
Also used : SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Test(org.junit.Test)

Example 32 with SpriteAnimated

use of com.b3dgs.lionengine.graphic.SpriteAnimated 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());
}
Also used : SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Animation(com.b3dgs.lionengine.Animation) Test(org.junit.Test)

Example 33 with SpriteAnimated

use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.

the class SpriteAnimatedTest method testConstructorMedia.

/**
 * Test constructor with media.
 */
@Test
public void testConstructorMedia() {
    final SpriteAnimated sprite = new SpriteAnimatedImpl(media, 16, 8);
    Assert.assertFalse(sprite.isLoaded());
    Assert.assertNull(sprite.getSurface());
    Assert.assertEquals(64, sprite.getWidth());
    Assert.assertEquals(32, sprite.getHeight());
    Assert.assertEquals(4, sprite.getTileWidth());
    Assert.assertEquals(4, sprite.getTileHeight());
    Assert.assertEquals(16, sprite.getFramesHorizontal());
    Assert.assertEquals(8, sprite.getFramesVertical());
}
Also used : SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Test(org.junit.Test)

Aggregations

SpriteAnimated (com.b3dgs.lionengine.graphic.SpriteAnimated)33 Test (org.junit.Test)33 Animation (com.b3dgs.lionengine.Animation)6 ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)3 Media (com.b3dgs.lionengine.Media)1 FilterBilinear (com.b3dgs.lionengine.core.filter.FilterBilinear)1 Graphic (com.b3dgs.lionengine.graphic.Graphic)1