Component for playing sound effects from game objects.
More...
#include <audio/Emitter.hpp>
|
bool | loop |
| Whether the sound should loop when playing.
|
|
double | volume |
| Volume level from 0.0 to 1.0.
|
|
int | channel |
| Current audio channel ID, or -1 if not playing.
|
|
|
class | StevEngine::GameObject |
|
|
std::vector< std::pair< Utilities::ID, std::string > > | handlers |
| Event handler registrations.
|
|
Component for playing sound effects from game objects.
The Emitter component allows game objects to play audio files. It supports one-shot and looping sounds with configurable volume levels.
◆ Emitter() [1/2]
StevEngine::Audio::Emitter::Emitter |
( |
std::string | audioPath, |
|
|
bool | loop = false, |
|
|
double | volume = 1 ) |
Create a new audio emitter.
- Parameters
-
audioPath | Path to the audio file to play |
loop | Whether the sound should loop |
volume | Initial volume level from 0.0 to 1.0 |
◆ Emitter() [2/2]
Create emitter from text serialized data.
- Parameters
-
stream | Stream containing serialized component data |
◆ ChangeSource()
void StevEngine::Audio::Emitter::ChangeSource |
( |
std::string | path | ) |
|
Change the audio source file.
- Parameters
-
path | Path to new audio file |
Loads a new audio file, freeing the previous one if loaded.
◆ Export()
Utilities::Stream StevEngine::Audio::Emitter::Export |
( |
Utilities::StreamType | type | ) |
const |
|
virtual |
Serialize component to a stream.
- Parameters
-
type | Type of stream to export to |
- Returns
- Serialized stream
Implements StevEngine::Component.
◆ GetData()
Mix_Chunk * StevEngine::Audio::Emitter::GetData |
( |
| ) |
const |
|
inline |
Get the raw audio data.
- Returns
- Pointer to loaded audio chunk
◆ GetType()
std::string StevEngine::Audio::Emitter::GetType |
( |
| ) |
const |
|
inlinevirtual |
◆ isPlaying()
bool StevEngine::Audio::Emitter::isPlaying |
( |
| ) |
const |
|
inline |
Check if sound is currently playing.
- Returns
- true if sound is playing, false otherwise
◆ Play()
void StevEngine::Audio::Emitter::Play |
( |
| ) |
|
Play the sound.
Starts playing the loaded audio file. If the sound is already playing, it will be stopped and restarted.
The documentation for this class was generated from the following files: