Search in sources :

Example 1 with Spawner

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;
        }
    };
}
Also used : Rasterable(com.b3dgs.lionengine.game.feature.rasterable.Rasterable) MapTilePersister(com.b3dgs.lionengine.game.feature.tile.map.persister.MapTilePersister) SourceResolutionProvider(com.b3dgs.lionengine.graphic.engine.SourceResolutionProvider) Transformable(com.b3dgs.lionengine.game.feature.Transformable) IOException(java.io.IOException) CameraTracker(com.b3dgs.lionengine.game.feature.CameraTracker) FileReading(com.b3dgs.lionengine.io.FileReading) HandlerPersister(com.b3dgs.lionengine.game.feature.HandlerPersister) Services(com.b3dgs.lionengine.game.feature.Services) WorldGame(com.b3dgs.lionengine.game.feature.WorldGame) Spawner(com.b3dgs.lionengine.game.feature.Spawner) Media(com.b3dgs.lionengine.Media) Optional(java.util.Optional) ComponentCollision(com.b3dgs.lionengine.game.feature.collidable.ComponentCollision) FileWriting(com.b3dgs.lionengine.io.FileWriting) Featurable(com.b3dgs.lionengine.game.feature.Featurable) Optional(java.util.Optional) Media(com.b3dgs.lionengine.Media) Transformable(com.b3dgs.lionengine.game.feature.Transformable) Spawner(com.b3dgs.lionengine.game.feature.Spawner) Featurable(com.b3dgs.lionengine.game.feature.Featurable)

Aggregations

Media (com.b3dgs.lionengine.Media)1 CameraTracker (com.b3dgs.lionengine.game.feature.CameraTracker)1 Featurable (com.b3dgs.lionengine.game.feature.Featurable)1 HandlerPersister (com.b3dgs.lionengine.game.feature.HandlerPersister)1 Services (com.b3dgs.lionengine.game.feature.Services)1 Spawner (com.b3dgs.lionengine.game.feature.Spawner)1 Transformable (com.b3dgs.lionengine.game.feature.Transformable)1 WorldGame (com.b3dgs.lionengine.game.feature.WorldGame)1 ComponentCollision (com.b3dgs.lionengine.game.feature.collidable.ComponentCollision)1 Rasterable (com.b3dgs.lionengine.game.feature.rasterable.Rasterable)1 MapTilePersister (com.b3dgs.lionengine.game.feature.tile.map.persister.MapTilePersister)1 SourceResolutionProvider (com.b3dgs.lionengine.graphic.engine.SourceResolutionProvider)1 FileReading (com.b3dgs.lionengine.io.FileReading)1 FileWriting (com.b3dgs.lionengine.io.FileWriting)1 IOException (java.io.IOException)1 Optional (java.util.Optional)1