use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.
the class SceneRasterable method load.
@Override
public void load() {
final SetupSurfaceRastered setup = new SetupSurfaceRastered(Medias.create("object.xml"), Medias.create("raster.xml"));
final SpriteAnimated surface = Drawable.loadSpriteAnimated(setup.getSurface(), 4, 4);
final Featurable featurable = new FeaturableModel();
featurable.addFeature(new MirrorableModel());
featurable.addFeature(new AnimatableModel(surface));
final Transformable transformable = featurable.addFeatureAndGet(new TransformableModel());
final Rasterable rasterable = new RasterableModel(services, setup);
rasterable.setOrigin(Origin.MIDDLE);
featurable.addFeature(rasterable);
featurable.addFeature(new RefreshableModel(extrp -> {
transformable.setLocationY(UtilMath.sin(count * 3) * 240);
surface.setLocation(camera, transformable);
rasterable.update(extrp);
surface.update(extrp);
}));
featurable.addFeature(new DisplayableModel(g -> rasterable.render(g)));
transformable.setLocationX(120);
handler.add(featurable);
camera.setView(0, 0, getWidth(), getHeight(), getHeight());
timing.start();
}
use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.
the class SpriteAnimatedTest method testSetAlpha.
/**
* Test set alpha.
*/
@Test
public void testSetAlpha() {
final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
for (int alpha = 0; alpha < 256; alpha++) {
sprite.setAlpha(alpha);
Assert.assertEquals(64, sprite.getWidth());
Assert.assertEquals(32, sprite.getHeight());
}
}
use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.
the class SpriteAnimatedTest method testSetAlphaHigh.
/**
* Test set alpha too high.
*/
@Test(expected = LionEngineException.class)
public void testSetAlphaHigh() {
final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
sprite.setAlpha(256);
}
use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.
the class SpriteAnimatedTest method testSetFade.
/**
* Test set fade.
*/
@Test
public void testSetFade() {
final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
sprite.setFade(128, 128);
sprite.setFade(128, 128);
Assert.assertEquals(64, sprite.getWidth());
Assert.assertEquals(32, sprite.getHeight());
}
use of com.b3dgs.lionengine.graphic.SpriteAnimated in project lionengine by b3dgs.
the class SpriteAnimatedTest method testSetOriginNull.
/**
* Test origin <code>null</code>.
*/
@Test(expected = LionEngineException.class)
public void testSetOriginNull() {
final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
sprite.setOrigin(null);
}
Aggregations