Search in sources :

Example 6 with Sprite

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

the class SpriteTest method testMirror.

/**
 * Test the mirror.
 */
@Test
public void testMirror() {
    final Sprite sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
    Assert.assertEquals(Mirror.NONE, sprite.getMirror());
    sprite.setMirror(Mirror.HORIZONTAL);
    Assert.assertEquals(Mirror.HORIZONTAL, sprite.getMirror());
}
Also used : Sprite(com.b3dgs.lionengine.graphic.Sprite) Test(org.junit.Test)

Example 7 with Sprite

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

the class SpriteTest method testConstructorSurface.

/**
 * Test constructor with surface.
 */
@Test
public void testConstructorSurface() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final Sprite sprite = new SpriteImpl(surface);
    Assert.assertTrue(sprite.isLoaded());
    Assert.assertEquals(surface, sprite.getSurface());
    Assert.assertEquals(64, sprite.getWidth());
    Assert.assertEquals(32, sprite.getHeight());
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Sprite(com.b3dgs.lionengine.graphic.Sprite) Test(org.junit.Test)

Example 8 with Sprite

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

the class SpriteTest method testSetTransparency.

/**
 * Test set transparency.
 */
@Test
public void testSetTransparency() {
    final Sprite sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
    sprite.setTransparency(ColorRgba.BLACK);
    Assert.assertEquals(64, sprite.getWidth());
    Assert.assertEquals(32, sprite.getHeight());
}
Also used : Sprite(com.b3dgs.lionengine.graphic.Sprite) Test(org.junit.Test)

Example 9 with Sprite

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

the class SpriteTest method testSetOriginNull.

/**
 * Test origin <code>null</code>.
 */
@Test(expected = LionEngineException.class)
public void testSetOriginNull() {
    final Sprite sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
    sprite.setOrigin(null);
}
Also used : Sprite(com.b3dgs.lionengine.graphic.Sprite) Test(org.junit.Test)

Example 10 with Sprite

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

the class SpriteTest method testRotate.

/**
 * Test rotate sprite.
 */
@Test
public void testRotate() {
    final Sprite sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
    for (int angle = -720; angle < 720; angle++) {
        sprite.rotate(angle);
        Assert.assertTrue(angle + Constant.SPACE + sprite.getWidth(), sprite.getWidth() >= 64);
        Assert.assertTrue(angle + Constant.SPACE + sprite.getHeight(), sprite.getHeight() >= 32);
    }
}
Also used : Sprite(com.b3dgs.lionengine.graphic.Sprite) Test(org.junit.Test)

Aggregations

Sprite (com.b3dgs.lionengine.graphic.Sprite)22 Test (org.junit.Test)22 ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)3 FilterBilinear (com.b3dgs.lionengine.core.filter.FilterBilinear)1 Graphic (com.b3dgs.lionengine.graphic.Graphic)1