SDXFrameWork  0.07
SDXFrameWork
 全て クラス ネームスペース 関数 変数 列挙型 列挙型の値 ページ
Music.h
1 #pragma once//☀SDL
2 #include <Multimedia/SDX.h>
3 
4 namespace SDX
5 {
8 class Music
9 {
10  friend class System;
11 private:
12  std::string fileName;
13  int volume;
14  Mix_Music* handle;
15  static int nowVolume;
16 public:
17  Music(){};
18  ~Music(){};
19 
21  Music(const char *ファイル名 , double 音量 = 1.0)
22  {
23  Music::Load( ファイル名 , 音量 );
24  }
25 
28  void Load(const char *ファイル名 , double 音量 = 1.0)
29  {
30  this->fileName = ファイル名;
31 
32  handle = Mix_LoadMUS(ファイル名);
33 
34  volume = int(音量*255);
35  }
36 
40  bool Play(PlayType 再生方法 = PlayType::Loop)
41  {
42  switch (再生方法)
43  {
44  case PlayType::Back:
45  Mix_PlayMusic(handle, 1);
46  break;
47  case PlayType::Loop:
48  Mix_PlayMusic(handle, -1);
49  break;
50  }
51  Mix_VolumeMusic(volume/2);
52  nowVolume = volume / 2;
53 
54  return true;
55  }
56 
58  void SetVolume(double 音量)
59  {
60  volume = int(音量*255);
61  }
62 
65  static bool Check()
66  {
67  return !Mix_PlayingMusic();
68  }
69 
71  static bool Stop()
72  {
73  return !Mix_HaltMusic();
74  }
75 
78  static void ChangeVolume(double 音量)
79  {
80  Mix_VolumeMusic(int(音量*255));
81  }
82 
83 };
84 }
再生中、他の処理を止めない
ライブラリの初期化やシステム的な処理を行う関数群.
Definition: System.h:13
static bool Stop()
再生中のMusicを停止.
Definition: Music.h:71
BGM用音声を表すクラス.
Definition: Music.h:8
static void ChangeVolume(double 音量)
再生中の音量を変更.
Definition: Music.h:78
void Load(const char *ファイル名, double 音量=1.0)
音声ファイルを登録.
Definition: Music.h:28
void SetVolume(double 音量)
0~1.0で音量を設定.
Definition: Music.h:58
static bool Check()
再生中か取得.
Definition: Music.h:65
Music(const char *ファイル名, double 音量=1.0)
音声ファイルを登録.
Definition: Music.h:21
他の処理を止めず、繰り返す
bool Play(PlayType 再生方法=PlayType::Loop)
音声ファイルを再生.
Definition: Music.h:40
PlayType
音声の再生方式.
Definition: Sound.h:7