use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.
the class SpriteAnimatedTest method testStretch.
/**
* Test stretch sprite.
*/
@Test
public void testStretch() {
final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
sprite.stretch(100.0, 100.0);
Assert.assertEquals(64, sprite.getWidth());
Assert.assertEquals(32, sprite.getHeight());
Assert.assertEquals(4, sprite.getTileWidth());
Assert.assertEquals(4, sprite.getTileHeight());
sprite.stretch(200.0, 100.0);
Assert.assertEquals(128, sprite.getWidth());
Assert.assertEquals(32, sprite.getHeight());
Assert.assertEquals(8, sprite.getTileWidth());
Assert.assertEquals(4, sprite.getTileHeight());
sprite.stretch(100.0, 200.0);
Assert.assertEquals(128, sprite.getWidth());
Assert.assertEquals(64, sprite.getHeight());
Assert.assertEquals(8, sprite.getTileWidth());
Assert.assertEquals(8, sprite.getTileHeight());
sprite.stretch(200.0, 200.0);
Assert.assertEquals(256, sprite.getWidth());
Assert.assertEquals(128, sprite.getHeight());
Assert.assertEquals(16, sprite.getTileWidth());
Assert.assertEquals(16, sprite.getTileHeight());
}
use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.
the class SpriteAnimatedTest method testUpdateNoLoopReverse.
/**
* Test update without loop but reverse.
*/
@Test
public void testUpdateNoLoopReverse() {
final Animation animation = new Animation(Animation.DEFAULT_NAME, 1, 3, 1.0, true, 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.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.FINISHED, sprite.getAnimState());
Assert.assertEquals(1, sprite.getFrame());
Assert.assertEquals(1, sprite.getFrameAnim());
}
use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.
the class SetupSurfaceRasteredTest method testConfigSmooth.
/**
* Test the setup surface rastered config.
*/
@Test
public void testConfigSmooth() {
final Media raster = Medias.create(RASTER_XML);
final SetupSurfaceRastered setup = new SetupSurfaceRastered(Medias.create(OBJECT_SMOOTH_XML), raster);
Assert.assertEquals(raster, setup.getFile());
Assert.assertTrue(setup.hasSmooth());
for (final SpriteAnimated sprite : setup.getRasters()) {
Assert.assertEquals(setup.getSurface().getWidth(), sprite.getSurface().getWidth());
Assert.assertEquals(setup.getSurface().getHeight(), sprite.getSurface().getHeight());
}
UtilFolder.deleteDirectory(Medias.create("void").getFile().getParentFile());
}
use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.
the class SpriteAnimatedTest method testConstructorSurface.
/**
* Test constructor with surface.
*/
@Test
public void testConstructorSurface() {
final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
final SpriteAnimated sprite = new SpriteAnimatedImpl(surface, 16, 8);
Assert.assertTrue(sprite.isLoaded());
Assert.assertEquals(surface, 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());
}
use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.
the class SpriteAnimatedTest method testStretchInvalidWidth.
/**
* Test stretch sprite with invalid width.
*/
@Test(expected = LionEngineException.class)
public void testStretchInvalidWidth() {
final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
sprite.stretch(0.0, 100.0);
}
Aggregations