Game Development Reference
In-Depth Information
Figure 15-11 . Add the private AudioClip compound declaration statement for your iSound0 through iSound5 objects
As you can see in Figure 15-11 , you will have to use the Alt-Enter work process,
and select the “Add import for javafx.scene.media.AudioClip” option, and have
NetBeans 8 write your AudioClip class import statement for you.
Referencing AudioClip Assets: Using the
java.net.URL Class
Unlike Image objects in JavaFX, which can be referenced using a simple forward slash
character and the file name, digital audio assets are not as simple to reference, and re-
quire the use of the URL class, which is part of the java.net (network) package. The
URL class is used to create a URL object, which provides a Uniform Resource Locator
(URL) file reference, which is essentially a “pointer” to a “data resource,” which is
usually a new media asset, and in the case of our Java 8 game development, it is a
WAVE audio file in our /src folder.
Like the AudioClip class, the URL class was also scratch coded to provide URL
objects, as you can see from the Java class hierarchy, which looks like the following:
 
Search WWH ::




Custom Search