use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.
the class SpriteAnimatedTest method testRotate.
/**
* Test rotate sprite.
*/
@Test
public void testRotate() {
final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
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);
}
}
use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.
the class SpriteAnimatedTest method testLoadMediaAlready.
/**
* Test load with media already loaded.
*/
@Test(expected = LionEngineException.class)
public void testLoadMediaAlready() {
final SpriteAnimated sprite = new SpriteAnimatedImpl(media, 16, 8);
sprite.load();
sprite.load();
}
use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.
the class SpriteAnimatedTest method testSetFrameOffset.
/**
* Test set frame offset.
*/
@Test
public void testSetFrameOffset() {
final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
sprite.setFrameOffsets(1, -1);
Assert.assertEquals(1, sprite.getFrameOffsetX());
Assert.assertEquals(-1, sprite.getFrameOffsetY());
}
use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.
the class SpriteAnimatedTest method testUpdateLoopNoReverse.
/**
* Test update with loop but no reverse.
*/
@Test
public void testUpdateLoopNoReverse() {
final Animation animation = new Animation(Animation.DEFAULT_NAME, 1, 3, 1.0, false, 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.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());
}
use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.
the class SpriteAnimatedTest method testFilterNull.
/**
* Test filter <code>null</code>.
*/
@Test(expected = LionEngineException.class)
public void testFilterNull() {
final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
sprite.filter(null);
}
Aggregations