use of com.b3dgs.lionengine.graphic.drawable.SpriteAnimated in project lionengine by b3dgs.
the class RasterableModel method setRaster.
@Override
public void setRaster(boolean save, Media media, int rasterHeight, Collection<Integer> allowed) {
if (setupRastered.isExtern()) {
Check.notNull(media);
Check.superiorStrict(rasterHeight, 0);
this.media = Optional.of(media);
this.rasterHeight = rasterHeight;
setupRastered.load(save, media, allowed);
rastersAnim.clear();
count = -1;
final List<ImageBuffer> buffers = setupRastered.getRasters();
final int n = buffers.size();
for (int i = 0; i < n; i++) {
final SpriteAnimated sprite = Drawable.loadSpriteAnimated(buffers.get(i), raster.getFramesHorizontal(), raster.getFramesVertical());
rastersAnim.add(sprite);
count++;
}
if (rastersAnim.size() < 2) {
updater = UpdatableVoid.getInstance();
} else {
updater = extrp -> updateRasterAnim();
}
}
}
use of com.b3dgs.lionengine.graphic.drawable.SpriteAnimated in project lionengine by b3dgs.
the class SceneRasterable method add.
private void add(SetupSurfaceRastered setup, int offsetX) {
final SpriteAnimated surface = Drawable.loadSpriteAnimated(setup.getSurface(), 4, 4);
final Featurable featurable = new FeaturableModel(services, setup);
featurable.addFeature(new MirrorableModel(services, setup));
featurable.addFeature(new AnimatableModel(services, setup, surface));
final Transformable transformable = featurable.addFeatureAndGet(new TransformableModel(services, setup));
final Rasterable rasterable = new RasterableModel(services, setup);
rasterable.setOrigin(Origin.MIDDLE);
rasterable.setFrameOffsets(1, 2);
featurable.addFeature(rasterable);
featurable.addFeature(new RefreshableModel(extrp -> {
transformable.setLocationY(UtilMath.sin(count) * 240);
surface.setLocation(camera, transformable);
rasterable.update(extrp);
surface.update(extrp);
}));
featurable.addFeature(new DisplayableModel(g -> rasterable.render(g)));
transformable.setLocationX(120 + offsetX);
handler.add(featurable);
}
Aggregations