|
1 | 1 | # AudioGame.JS |
2 | 2 | Easily play optimized audio for your game! |
| 3 | +## Installation |
| 4 | + |
| 5 | +Add the following script tag to your HTML: |
| 6 | + |
| 7 | +```html |
| 8 | +< script src= "https://cdn.jsdelivr.net/gh/Creadores-Program/[email protected]/src/org/CreadoresProgram/AudioGameJS/AudioGame.js"></ script> |
| 9 | +``` |
| 10 | + |
| 11 | +## Basic Usage |
| 12 | + |
| 13 | +```js |
| 14 | +// Create an AudioGame instance |
| 15 | +const sound = new AudioGame('path/to/file.mp3', { |
| 16 | + loop: false, // Repeat audio (default: false) |
| 17 | + volume: 1, // Volume (0 to 1, default: 1) |
| 18 | + is3D: false, // 3D audio (default: false) |
| 19 | + pan: 0, // Stereo pan (-1 to 1, only if is3D is false) |
| 20 | + autoplay: false // Autoplay on load (default: false) |
| 21 | +}); |
| 22 | + |
| 23 | +// Play |
| 24 | +sound.play(); |
| 25 | + |
| 26 | +// Pause |
| 27 | +sound.pause(); |
| 28 | + |
| 29 | +// Change volume |
| 30 | +sound.volume = 0.5; |
| 31 | + |
| 32 | +// Change 3D position (if is3D is true) |
| 33 | +sound.setPosition3D(1, 0, 0); |
| 34 | +``` |
| 35 | + |
| 36 | +## API |
| 37 | + |
| 38 | +- **play()**: Play the audio. |
| 39 | +- **pause()**: Pause the audio. |
| 40 | +- **dispose()**: Release audio resources. |
| 41 | +- **volume**: Volume (0 to 1). |
| 42 | +- **loop**: Whether the audio repeats. |
| 43 | +- **pan**: Stereo pan (-1 to 1, only if is3D is false). |
| 44 | +- **is3D**: Enable 3D audio. |
| 45 | +- **setPosition3D(x, y, z)**: Set the 3D position of the audio. |
| 46 | +- **autoplay**: Whether the audio plays automatically on load. |
| 47 | +- **currentTime**: Current playback time. |
| 48 | +- **duration**: Audio duration. |
| 49 | +- **paused**: Whether the audio is paused. |
| 50 | +- **readyState**: 4 if loaded, 0 if not. |
| 51 | + |
| 52 | +## License |
| 53 | +MIT |
0 commit comments