SDXFrameWork  0.04
SDXFrameWork
 全て クラス ネームスペース 関数 変数 ページ
Music.h
1 #pragma once
2 #include <Multimedia/SDX.h>
3 #include <Multimedia/Window.h>
4 #include <Multimedia/Sound.h>
5 
6 namespace SDX
7 {
9 class Music
11 {
12 private:
13  std::string fileName;
14  int volume;
15 #ifdef SDL
16  Mix_Music* handle;
17 #endif
18 
19 public:
20  Music(){};
21  ~Music(){};
22 
24  Music(const char *ファイル名 , double 音量 = 1.0)
25  {
26  Music::Load( ファイル名 , 音量 );
27  }
28 
30  void Load(const char *ファイル名 , double 音量 = 1.0)
32  {
33  this->fileName = ファイル名;
34  #ifdef SDL
35  handle = Mix_LoadMUS(ファイル名);
36  #endif
37  volume = int(音量*255);
38  }
39 
41  bool Play(PlayType 再生方法 = PlayType::Back)
44  {
45  #ifdef DXLIB
46  const bool ok = !DxLib::PlayMusic(this->fileName.c_str(), (int)再生方法);
47  DxLib::SetVolumeMusic( volume );
48  return ok;
49  #elif defined(SDL)
50  switch (再生方法)
51  {
52  case PlayType::Back:
53  Mix_PlayMusic(handle, 1);
54  break;
55  case PlayType::Loop:
56  Mix_PlayMusic(handle, -1);
57  break;
58  }
59  Mix_VolumeMusic(volume/2);
60  return true;
61  #endif
62  }
63 
65  static bool Check()
67  {
68  #ifdef DXLIB
69  return !DxLib::CheckMusic();
70  #elif defined(SDL)
71  return !Mix_PlayingMusic();
72  #endif
73  }
74 
76  static bool Stop()
77  {
78  #ifdef DXLIB
79  return !DxLib::StopMusic();
80  #elif defined(SDL)
81  return !Mix_HaltMusic();
82  #endif
83  }
84 };
85 }
static bool Stop()
再生中のMusicを停止.
Definition: Music.h:76
bool Play(PlayType 再生方法=PlayType::Back)
音声ファイルを再生.
Definition: Music.h:43
void Load(const char *ファイル名, double 音量=1.0)
音声ファイルを登録.
Definition: Music.h:31
static bool Check()
再生中か取得.
Definition: Music.h:66
Music(const char *ファイル名, double 音量=1.0)
音声ファイルを登録.
Definition: Music.h:24