Game Development Reference
In-Depth Information
Here's how the Okqj` and Okqj`?d]jjah objects work together to play the Chimes sound.
1. First, you have to declare the Okqj` object. In the @kkn class, the Okqj` object is called [_deiao,
and is declared at the beginning of the class definition:
lner]par]n[_deiao6?deiao7
This refers to the actual sound file that you imported into the Library . Its type matches its sym-
bol name: ?deiao.
2. Next, you have to declare the Okqj`?d]jjah object. In the @kkn class, it's called
[okqj`?d]jjah.
lner]par]n[okqj`?d]jjah6Okqj`?d]jjah7
It's the job of the [okqj`?d]jjah object to actually play the sound.
3. Create the Okqj` and Okqj`?d]jjah objects. Like any other objects, you create them with the
jas operator:
[_deiao9jas?deiao$%7
[okqj`?d]jjah9jasOkqj`?d]jjah$%7
4. Play the sounds. You do this by assigning the Okqj` object to the Okqj`?d]jjah object, like
this:
[okqj`?d]jjah9[_deiao*lh]u$%7
The Okqj` object's lh]u method plays the sound. You can use this directive anywhere in the
class when you want the sound to play.
In the @kkn class, the chimes play when the [eoKlaj property becomes pnqa:
eb$[eoKlaj%
w
[okqj`?d]jjah9[_deiao*lh]u$%7
reoe^ha9b]hoa7
y
ahoa
w
reoe^ha9pnqa7
y
This has been a brief introduction to using sound in games, but it's by no means the end of it. For
much more information on using sound, visit Adobe's online documentation at dppl6++dahl*]`k^a*
_ki+aj[QO+=_pekjO_nelp+/*,[Lnkcn]iiejc=O/+ and see the chapter “Working with Sound.”
 
Search Nedrilad ::




Custom Search