use of com.b3dgs.lionengine.game.feature.Spawner in project lionengine by b3dgs.
the class WorldHelper method createSpawner.
@Override
protected Spawner createSpawner() {
return new Spawner() {
private Optional<Media> raster = Optional.empty();
@Override
public void setRaster(Media raster) {
this.raster = Optional.ofNullable(raster);
}
@Override
public Featurable spawn(Media media, double x, double y) {
final Featurable f = factory.create(media);
f.getFeature(Transformable.class).teleport(x, y);
f.ifIs(Rasterable.class, r -> raster.ifPresent(m -> r.setRaster(true, m, map.getTileHeight())));
handler.add(f);
return f;
}
};
}
Aggregations