Search in sources :

Example 11 with SpriteAnimated

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

the class SpriteAnimatedTest method testFilterBilinear.

/**
 * Test filter bilinear.
 */
@Test
public void testFilterBilinear() {
    final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    sprite.filter(new FilterBilinear());
    Assert.assertEquals(64, sprite.getWidth());
    Assert.assertEquals(32, sprite.getHeight());
}
Also used : SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) FilterBilinear(com.b3dgs.lionengine.core.filter.FilterBilinear) Test(org.junit.Test)

Example 12 with SpriteAnimated

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

the class SpriteAnimatedTest method testSetSpeed.

/**
 * Test set speed.
 */
@Test
public void testSetSpeed() {
    final Animation animation = new Animation(Animation.DEFAULT_NAME, 1, 3, 1.0, false, false);
    final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    sprite.play(animation);
    sprite.setAnimSpeed(2.0);
    sprite.update(1.0);
    Assert.assertEquals(AnimState.PLAYING, sprite.getAnimState());
    Assert.assertEquals(3, sprite.getFrame());
    Assert.assertEquals(3, sprite.getFrameAnim());
}
Also used : SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Animation(com.b3dgs.lionengine.Animation) Test(org.junit.Test)

Example 13 with SpriteAnimated

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

the class SpriteAnimatedTest method testSetSpeedNegative.

/**
 * Test invalid speed setter.
 */
@Test(expected = LionEngineException.class)
public void testSetSpeedNegative() {
    final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    sprite.setAnimSpeed(-1.0);
}
Also used : SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Test(org.junit.Test)

Example 14 with SpriteAnimated

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

the class SpriteAnimatedTest method testSetAlphaLow.

/**
 * Test set alpha too low.
 */
@Test(expected = LionEngineException.class)
public void testSetAlphaLow() {
    final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    sprite.setAlpha(-1);
}
Also used : SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Test(org.junit.Test)

Example 15 with SpriteAnimated

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

the class SpriteAnimatedTest method testMirror.

/**
 * Test mirror.
 */
@Test
public void testMirror() {
    final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    Assert.assertEquals(Mirror.NONE, sprite.getMirror());
    sprite.setMirror(Mirror.HORIZONTAL);
    Assert.assertEquals(Mirror.HORIZONTAL, sprite.getMirror());
}
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