1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
Sound
=====
The Sound object lets you play samples, which are short sounds like: jump, brake, select, hit, etc. Sounds are loaded entirely in the memory; therefore, this object is meant to be used only with samples. If you need to play longer things like music, consider using [Music](/engine/music) instead.
*Example*
```
using SurgeEngine.Audio.Sound;
// will play a sound every 5 seconds
object "SoundTest"
{
sound = Sound("samples/jump.wav");
state "main"
{
sound.play();
state = "wait";
}
state "wait"
{
if(timeout(5.0))
state = "main";
}
}
```
Factory
-------
#### Sound
`Audio.Sound(path)`
Creates a Sound object associated with a certain file.
*Arguments*
* `path`: string. The path of the sound - usually a file in the *samples/* folder.
*Returns*
A Sound object.
Properties
----------
#### playing
`playing`: boolean, read-only.
Will be `true` if the sound is playing.
#### volume
`volume`: number.
The volume of the sound, a value between 0.0 and 1.0, inclusive (zero means silence).
Functions
---------
#### play
`play()`
Plays the sound.
#### stop
`stop()`
Stops the sound.
|