Métodos públicos | |
| void | setName (string &name) |
| string | getName () |
| void | play () |
| void | stop () |
| void | pause () |
| void | setVolume (float volume) |
| float | getVolume () |
| void | setRepeat (bool repeat) |
| bool | getRepeat () |
| int | getLength () |
| int | getPosition () |
| void | setPan (float pan) |
| float | getPan () |
| bool | isPlaying () |
| bool | isPaused () |
Amigas | |
| class | SoundMgr |
bool TestGame::OnInit() { // Intentamos inicializar el // dispositivo de sonido if (!SoundMgr::openDevice()) return false; // Abrimos un archivo de música // en caso de error, el método // retornará NULL _music = SoundMgr::openSound("./data/machinae_supremacy_-_steves_quest.mp3", true); // Si hubo algún error, // retornamos false if (!_music) { return false; } // Indicamos que deseamos que // se repita indefinidamente _music->setRepeat(true); // Corremos la música _music->play(); // Abrimos un nuevo sonido _sound = SoundMgr::openSound("./data/Bubble.wav", false); // Verificamos si hubo algún error if (!_sound) { return false; } // Indicamos que no deseamos que // se repita _sound->setRepeat(false); // Indicamos el volumen al máximo // para todos los sonidos SoundMgr::setGlobalVolume(0.5f); return true; } void TestGame::OnFrame() { if (KeyDown(DIK_ESCAPE)) PostQuitMessage(0); // Si mantenemos presionada la tecla S // y el sonido no se está reproduciendo // lo reproducimos de nuevo if (KeyPressed(DIK_S) && !_sound->isPlaying()) { _sound->stop(); _sound->play(); } // Si presionamos P pausaremos y // volveremos a reproducir la música if (KeyDown(DIK_P)) { if(_music->isPlaying()) { _music->pause(); } else { _music->play(); } } // Si presionamos la barra espaciadora // cortaremos la reproduccion de la música // y volveremos a iniciarla if (KeyDown(DIK_SPACE)) { if(_music->isPlaying()) { _music->stop(); } else { _music->play(); } } } bool TestGame::OnShutdown() { SoundMgr::closeSound(_music); SoundMgr::closeSound(_sound); return true; }
| void zak::Sound::setName | ( | string & | name | ) | [inline] |
Permite indicar un nombre para el sonido. Por defecto será la ruta y el nombre del archivo cargado
| name | cadena de caracteres terminada en con el nombre del sonido |
| string zak::Sound::getName | ( | ) | [inline] |
Devuelve el nombre del sonido
| void zak::Sound::play | ( | ) | [inline] |
Reproduce el sonido
| void zak::Sound::stop | ( | ) | [inline] |
Para el sonido
| void zak::Sound::pause | ( | ) | [inline] |
Pausa el sonido
| void zak::Sound::setVolume | ( | float | volume | ) | [inline] |
Permite indicar el volumen del sonido entre 0.0f y 1.0f
| volume | volumen del sonido |
| float zak::Sound::getVolume | ( | ) | [inline] |
Retorna el volumen del sonido entre 0.0f y 1.0f
| void zak::Sound::setRepeat | ( | bool | repeat | ) | [inline] |
Permite indicar si deseamos que el sonido se reproduzca indefinidamente
| repeat | define si deseamos que se repita indefinidamente el sonido |
| bool zak::Sound::getRepeat | ( | ) | [inline] |
Retorna si deseamos que el sonido se reproduzca indefinidamente
| int zak::Sound::getLength | ( | ) | [inline] |
Devuelve la longitud del sonido
| int zak::Sound::getPosition | ( | ) | [inline] |
Devuelve la posición que se está reproduciendo del sonido
| void zak::Sound::setPan | ( | float | pan | ) | [inline] |
Permite indicar el balance entre los parlantes izquierdo y derecho. Debe ser un rango entre -1.0f y 1.0f (por defecto 0.0f)
| pan | balance entre los parlantes izquierdo y derecho (-1.0f y 1.0f) |
| float zak::Sound::getPan | ( | ) | [inline] |
Devuelve el balance entre los parlantes izquierdo y derecho. Debe ser un rango entre -1.0f y 1.0f (por defecto 0.0f)
| bool zak::Sound::isPlaying | ( | ) | [inline] |
Devuelve si el sonido se está reproduciendo o no
1.5.1-p1