CCIMXDesktop
 
Loading...
Searching...
No Matches
SoundEffectPlayer.h
1#ifndef SOUNDEFFECTPLAYER_H
2#define SOUNDEFFECTPLAYER_H
3
4#include <QList>
5#include <QObject>
6
7class QSoundEffect;
8
13class SoundEffectPlayer : QObject {
14public:
19 enum class EffectIndex {
20 JUMP,
21 SCORE,
22 DIE
23 };
24
30 static constexpr int index(const EffectIndex& e) {
31 return static_cast<int>(e);
32 }
33
39 static constexpr EffectIndex index(const int e) {
40 return static_cast<EffectIndex>(e);
41 }
42
47 static constexpr int max_cnt() {
49 }
50
55 explicit SoundEffectPlayer(QObject* parent);
56
62
63private:
64 QList<QSoundEffect*> effects;
65
69 void init_sound_effect();
70
76 void setup_soundeffect(EffectIndex index, const char* src);
77};
78
79#endif // SOUNDEFFECTPLAYER_H
Handles playback of sound effects.
Definition SoundEffectPlayer.h:13
EffectIndex
Indexes for different sound effects.
Definition SoundEffectPlayer.h:19
@ JUMP
Jump sound effect.
@ DIE
Death sound effect.
@ SCORE
Score sound effect.
static constexpr EffectIndex index(const int e)
Converts integer to EffectIndex.
Definition SoundEffectPlayer.h:39
void play(EffectIndex index)
Plays specified sound effect.
Definition SoundEffectPlayer.cpp:9
static constexpr int max_cnt()
Gets total number of sound effects.
Definition SoundEffectPlayer.h:47
static constexpr int index(const EffectIndex &e)
Converts EffectIndex to integer.
Definition SoundEffectPlayer.h:30