SDXFrameWork  0.04
SDXFrameWork
 全て クラス ネームスペース 関数 変数 ページ
Director.h
1 #pragma once
2 #include <Framework/IScene.h>
3 #include <Utility/Timer.h>
4 #include <Multimedia/Input.h>
5 #include <Framework/Camera.h>
6 
7 namespace SDX
8 {
10 class Director
12 {
13 private:
14  std::list< std::shared_ptr<IScene> > scenes;
15 
16  Director(){};
17 
18  static Director& Single()
19  {
20  static Director instance;
21  return instance;
22  }
23 public:
25  static void Run()
26  {
28 
29  while( System::Update() )
30  {
31  if( Single().scenes.size() == 0 ) break;
32  Single().scenes.back()->Update();
33  Single().scenes.back()->Draw();
34  //更新処理
35  if( Camera::Now() ) Camera::Now()->Update();
37 
38  Remove();
39  }
40  }
41 
43  static void Remove()
44  {
45  auto it = Single().scenes.begin();
46 
47  while( it != Single().scenes.end() )
48  {
49  if( (*it)->IsEnd() )
50  {
51  Single().scenes.remove( (*it) );
52  if(Single().scenes.size() == 0 )break;
53  continue;
54  }
55  it++;
56  }
57  }
58 
60  static void SetActive( IScene* scene )
61  {
62  //既に存在する場合追加のみ
63  auto it = Single().scenes.begin();
64  while( it != Single().scenes.end() )
65  {
66  if( (*it).get() == scene )
67  {
68  Single().scenes.push_back( std::shared_ptr<IScene>(scene) );
69  Single().scenes.remove( (*it) );
70  return;
71  }
72  break;
73  }
74  //存在していない場合初期化もする
75  scene->Init();
76  Single().scenes.push_back( std::shared_ptr<IScene>(scene) );
77  }
78 };
79 }
80 
81 
82 
83 
84 
85 
86 
87 
88 
void Update()
追跡方法や速度に応じてカメラ位置の更新.
Definition: Camera.h:138
static void SetActive(IScene *scene)
Sceneをアクティブにする.
Definition: Director.h:60
static bool Update(bool 描画更新フラグ=true)
各種更新処理をまとめて行う.
Definition: System.h:80
シーンのインターフェース.
Definition: IScene.h:6
static Camera * Now()
アクティブなカメラを取得.
Definition: Camera.h:54
static void Run()
実行開始.
Definition: Director.h:25
static void CheckFPS()
FPS計測を更新.
Definition: Timer.h:66
static void ResetFPS()
FPSの計測開始.
Definition: Timer.h:60
static void Remove()
消滅したSceneを片付ける.
Definition: Director.h:43