Module hanyaeger

Class BackgroundDelegate

java.lang.Object
com.github.hanyaeger.core.scenes.delegates.BackgroundDelegate
All Implemented Interfaces:
Destroyable, ResourceConsumer

public class BackgroundDelegate extends Object implements ResourceConsumer, Destroyable
A BackgroundDelegate follows the Delegate pattern and embraces Composition over Inheritance. It can be used to deal with both background audio and background images for a YaegerScene.
  • Constructor Details

    • BackgroundDelegate

      public BackgroundDelegate()
  • Method Details

    • setup

      public void setup(javafx.scene.layout.Pane pane)
      Set up the Pane belonging to this BackgroundDelegate.
      Parameters:
      pane - The Pane that should be used when setup.
    • setBackgroundAudio

      public void setBackgroundAudio(String backgroundAudioUrl)
      Set the background audio. The audio will loop indefinite while the Scene is active.
      Parameters:
      backgroundAudioUrl - the url of the audio file
    • setBackgroundColor

      public void setBackgroundColor(javafx.scene.paint.Color color)
      Set the background color of the YaegerScene.
      Parameters:
      color - The Color of the background.
    • setBackgroundImage

      public void setBackgroundImage(String backgroundImageUrl, boolean fullscreen)
      Set the background image. The image will be set as the full background for the Scene.
      Parameters:
      backgroundImageUrl - The url of the image file. This is relative to the resource/ folder.
      fullscreen - a boolean that states whether the image should be fullscreen. If false the image will be horizontally and vertically tiled.
    • stopBackgroundAudio

      public void stopBackgroundAudio()
      Stop playing the background audio.
    • setVolume

      public void setVolume(double volume)
      Set the volume of the background audio.
      Parameters:
      volume - the volume
    • getVolume

      public double getVolume()
      Retrieves the background audio playback volume.
      Returns:
      the audio volume
    • destroy

      public void destroy()
      Description copied from interface: Destroyable
      Implement this method and use it to ensure that the maximum number of Objects are eligible for Garbage Collection after this method has been called.
      Specified by:
      destroy in interface Destroyable
    • setImageRepository

      @Inject public void setImageRepository(ImageRepository imageRepository)
      Set the ImageRepository to be used for this BackgroundDelegate.
      Parameters:
      imageRepository - the ImageRepository to be used
    • setBackgroundFactory

      @Inject public void setBackgroundFactory(BackgroundFactory backgroundFactory)
      Set the BackgroundFactory to be used for this BackgroundDelegate.
      Parameters:
      backgroundFactory - the BackgroundFactory to be used
    • setBackgroundAudioMediaPlayer

      @Inject public void setBackgroundAudioMediaPlayer(BackgroundAudioMediaPlayer backgroundAudioMediaPlayer)
      TSet the BackgroundAudioMediaPlayer to be used for this BackgroundDelegate.
      Parameters:
      backgroundAudioMediaPlayer - the BackgroundAudioMediaPlayer to be used