Game Development Reference
In-Depth Information
Now we are ready to use these six new .setiSound() methods that NetBeans has
coded for us, which we do not need, as our AudioClips are permanently “set” in
memory using the .loadAudioAssets() method, to create the six .playiSound() methods
that we do in fact need to play back these six digital audio assets. Let's do that next.
Providing Access to Your AudioClip: The .play-
iSound() Methods
What we are about to do is what I consider another programmer's shortcut, but instead
of copy and paste, I used NetBeans Source Insert Code function to create Setter
methods for the iSound objects that I am going to change from .setiSound() to .play-
iSound() methods, so that I do not have to type out all six of these method bodies. As
you can see in Figure 15-17 , NetBeans created six complete method bodies for us, and
all that we have to do is to remove the AudioClip iSound references inside of the meth-
od parameter areas, change the setiSound() to be playiSound(), and finally change the
this.iSound0 = iSound0; statement to be this.iSound0.play(); in-
stead. We will do this for each of the six .setiSound() method bodies, which will allow
us to quickly create six .playiSound() method bodies.
 
 
Search WWH ::




Custom Search