Hello! I’m creating a game with Slick2D library, and I have a problem to calculate fadeIn effect for a volume of the music. Sadly, class Music has a fadeOut method fade(duration, endVolume, stopAfterFade), but does not contain and fadeIn.
So I want to increase volume from 0.0f to 1.0f in 3s.
if (gameContainer.isMusicOn()) {
if (!music.playing()) {
music.play(1.0f, 0.0f);
}
int fadeInDuration = 3000;
if (startTime + fadeInDuration > gameContainer.getTime()) {
float increaseVol = music.getVolume() + 0.1f;
music.setVolume(vol);
}
}