Search in sources :

Example 6 with SpriteAnimated

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

the class SpriteAnimatedTest method testStop.

/**
 * Test stop.
 */
@Test
public void testStop() {
    final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    sprite.stop();
    Assert.assertEquals(AnimState.STOPPED, sprite.getAnimState());
}
Also used : SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Test(org.junit.Test)

Example 7 with SpriteAnimated

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

the class SpriteAnimatedTest method testLoadMedia.

/**
 * Test load with media.
 */
@Test
public void testLoadMedia() {
    final SpriteAnimated sprite = new SpriteAnimatedImpl(media, 16, 8);
    sprite.load();
    Assert.assertNotNull(sprite.getSurface());
    sprite.prepare();
    sprite.dispose();
}
Also used : SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Test(org.junit.Test)

Example 8 with SpriteAnimated

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

the class SpriteAnimatedTest method testRender.

/**
 * Test render.
 */
@Test
public void testRender() {
    final Graphic g = Graphics.createImageBuffer(100, 100).createGraphic();
    try {
        final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
        sprite.render(g);
        sprite.setFrame(1);
        sprite.setMirror(Mirror.HORIZONTAL);
        sprite.render(g);
        sprite.setMirror(Mirror.VERTICAL);
        sprite.render(g);
    } finally {
        g.dispose();
    }
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic) SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Test(org.junit.Test)

Example 9 with SpriteAnimated

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

the class SpriteAnimatedTest method testPlay.

/**
 * Test play.
 */
@Test
public void testPlay() {
    final Animation animation = new Animation(Animation.DEFAULT_NAME, 1, 2, 3.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());
}
Also used : SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Animation(com.b3dgs.lionengine.Animation) Test(org.junit.Test)

Example 10 with SpriteAnimated

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

the class SpriteAnimatedTest 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 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.REVERSING, sprite.getAnimState());
    Assert.assertEquals(2, sprite.getFrame());
    Assert.assertEquals(2, sprite.getFrameAnim());
    sprite.update(1.0);
    Assert.assertEquals(AnimState.REVERSING, 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.REVERSING, 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)

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