Search in sources :

Example 16 with Sprite

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

the class SpriteTest method testLoadMedia.

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

Example 17 with Sprite

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

the class SpriteTest method testSetAlphaHigh.

/**
 * Test set alpha too high.
 */
@Test(expected = LionEngineException.class)
public void testSetAlphaHigh() {
    final Sprite sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
    sprite.setAlpha(256);
}
Also used : Sprite(com.b3dgs.lionengine.graphic.Sprite) Test(org.junit.Test)

Example 18 with Sprite

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

the class SpriteTest method testHashCode.

/**
 * Test hash code.
 */
@Test
public void testHashCode() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final int sprite = new SpriteImpl(surface).hashCode();
    final Sprite spriteMedia = new SpriteImpl(media);
    spriteMedia.load();
    Assert.assertEquals(sprite, new SpriteImpl(surface).hashCode());
    Assert.assertNotEquals(sprite, new Object().hashCode());
    Assert.assertNotEquals(spriteMedia.hashCode(), new SpriteImpl(media).hashCode());
    Assert.assertNotEquals(sprite, new SpriteImpl(Graphics.createImageBuffer(64, 32)).hashCode());
    Assert.assertNotEquals(sprite, new SpriteImpl(Graphics.createImageBuffer(32, 32)).hashCode());
    Assert.assertNotEquals(sprite, new SpriteImpl(Graphics.createImageBuffer(64, 64)).hashCode());
    Assert.assertNotEquals(sprite, new SpriteImpl(Graphics.createImageBuffer(32, 64)).hashCode());
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Sprite(com.b3dgs.lionengine.graphic.Sprite) Test(org.junit.Test)

Example 19 with Sprite

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

the class SpriteTest method testStretchInvalidHeight.

/**
 * Test stretch sprite with invalid height.
 */
@Test(expected = LionEngineException.class)
public void testStretchInvalidHeight() {
    final Sprite sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
    sprite.stretch(100, 0.0);
}
Also used : Sprite(com.b3dgs.lionengine.graphic.Sprite) Test(org.junit.Test)

Example 20 with Sprite

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

the class SpriteTest method testFilterNull.

/**
 * Test filter <code>null</code>.
 */
@Test(expected = LionEngineException.class)
public void testFilterNull() {
    final Sprite sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
    sprite.filter(null);
}
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