java.lang.Object
com.github.hanyaeger.core.scenes.delegates.BackgroundDelegate
- All Implemented Interfaces:
Destroyable
,ResourceConsumer
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
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.double
Retrieves the background audio playback volume.void
setBackgroundAudio
(String backgroundAudioUrl) Set the background audio.void
setBackgroundAudioMediaPlayer
(BackgroundAudioMediaPlayer backgroundAudioMediaPlayer) TSet theBackgroundAudioMediaPlayer
to be used for thisBackgroundDelegate
.void
setBackgroundColor
(javafx.scene.paint.Color color) Set the background color of theYaegerScene
.void
setBackgroundFactory
(BackgroundFactory backgroundFactory) Set theBackgroundFactory
to be used for thisBackgroundDelegate
.void
setBackgroundImage
(String backgroundImageUrl, boolean fullscreen) Set the background image.void
setImageRepository
(ImageRepository imageRepository) Set theImageRepository
to be used for thisBackgroundDelegate
.void
setup
(javafx.scene.layout.Pane pane) Set up thePane
belonging to thisBackgroundDelegate
.void
setVolume
(double volume) Set the volume of the background audio.void
Stop playing the background audio.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.github.hanyaeger.core.ResourceConsumer
createPathForResource
-
Constructor Details
-
BackgroundDelegate
public BackgroundDelegate()
-
-
Method Details
-
setup
public void setup(javafx.scene.layout.Pane pane) Set up thePane
belonging to thisBackgroundDelegate
.- Parameters:
pane
- ThePane
that should be used when setup.
-
setBackgroundAudio
Set the background audio. The audio will loop indefinite while theScene
is active.- Parameters:
backgroundAudioUrl
- the url of the audio file
-
setBackgroundColor
public void setBackgroundColor(javafx.scene.paint.Color color) Set the background color of theYaegerScene
.- Parameters:
color
- TheColor
of the background.
-
setBackgroundImage
Set the background image. The image will be set as the full background for theScene
.- Parameters:
backgroundImageUrl
- The url of the image file. This is relative to the resource/ folder.fullscreen
- aboolean
that states whether the image should be fullscreen. Iffalse
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 interfaceDestroyable
-
setImageRepository
Set theImageRepository
to be used for thisBackgroundDelegate
.- Parameters:
imageRepository
- theImageRepository
to be used
-
setBackgroundFactory
Set theBackgroundFactory
to be used for thisBackgroundDelegate
.- Parameters:
backgroundFactory
- theBackgroundFactory
to be used
-
setBackgroundAudioMediaPlayer
@Inject public void setBackgroundAudioMediaPlayer(BackgroundAudioMediaPlayer backgroundAudioMediaPlayer) TSet theBackgroundAudioMediaPlayer
to be used for thisBackgroundDelegate
.- Parameters:
backgroundAudioMediaPlayer
- theBackgroundAudioMediaPlayer
to be used
-