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());
}
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();
}
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();
}
}
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());
}
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());
}
Aggregations