Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 21 ■ Questions and answers: Finishing the setup Methods and digital audio


Next, let’s create our camera Animation object audio, this time matching audio length to Animation length.

Camera Animation Audio: Matching Audio Length to Animation


For the camera object Animation AudioClip, we are going to match the five seconds of Animation with five
seconds of audio so that we do not need to loop the audio and therefore do also not need to use the stop()
method call, as the AudioClip will stop playing after its five to six seconds of length. It is important that you
see both of these primary digital audio approaches to gameplay design: looped audio started and stopped
as needed and timed audio. As you can see in Figure 21-38, I have chosen the Rhythmic Glacier sample
from the Project Pegasus Arpeggios collection and have trimmed it slightly to be around five-and-a-half
seconds in length. As you can see, this sample was 48000 Hz, so I also created 16000 Hz (1/3) and 8000 Hz
(1/6) medium- and low-quality 16-bit versions, which were 526KB, 176KB, and 88KB, respectively. This
puts CD-quality sound at about 1MB and good-quality sound at about half a megabyte.


Figure 21-38. Match almost six seconds of Rhythmic Glacier audio with almost six seconds of camera zoom
animation


Figure 21-37. Stop the spinnerAudio object in the createAnimationAssets() method in a rotGameBoard.
setOnFinished() event handler

Free download pdf