SDXFrameWork  0.13
SDXFrameWork
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Anime.h
1 //Copyright © 2014 SDXFramework
2 //[License]GNU Affero General Public License, version 3
3 //[Contact]http://sourceforge.jp/projects/dxframework/
4 #pragma once
5 #include <Framework/Film.h>
6 
7 namespace SDX
8 {
11  class Anime : public IDrawable
12  {
13  private:
14  const Film* film;
15  int direct = 1;
16  int frameNumber = 0;
17  double timer = 0;
18  public:
19 
21  Anime(const Film* 再生する対象) :
22  film(再生する対象)
23  {}
24 
27  bool Update(double 経過フレーム = 1)
28  {
29  timer += 経過フレーム;
30 
31  if (timer > film->times[frameNumber])
32  {
33  timer -= film->times[frameNumber];
34  switch (film->nexts[frameNumber])
35  {
36  case (int)NextFrame::Normal:
37  frameNumber += direct;
38  break;
39  case (int)NextFrame::ToFront:
40  direct = 1;
41  frameNumber += direct;
42  break;
43  case (int)NextFrame::ToBack:
44  direct = -1;
45  frameNumber += direct;
46  break;
47  case (int)NextFrame::End:
48  return false;
49  break;
50  default:
51  frameNumber = film->nexts[frameNumber];
52  break;
53  }
54 
55  if ((unsigned int)frameNumber >= film->imageS.size()) frameNumber = 0;
56  if (frameNumber < 0) frameNumber = (int)film->imageS.size() - 1;
57  }
58 
59  return true;
60  }
61 
63  Image* GetFrame() const
64  {
65  return film[0][frameNumber];
66  }
67 
70  void SetFrame(int コマ数)
71  {
72  if (コマ数 >= film->GetSize())
73  {
74  コマ数 = film->GetSize() - 1;
75  }
76  else if (コマ数 < 0)
77  {
78  コマ数 = 0;
79  }
80  frameNumber = コマ数;
81  timer = 0;
82  }
83 
85  bool Draw(const Point &座標, bool 反転フラグ = false) const override
86  {
87  return GetFrame()->Draw(座標, 反転フラグ);
88  }
89 
91  bool DrawExtend(const Rect &描画領域, bool 反転フラグ = false) const override
92  {
93  return GetFrame()->DrawExtend(描画領域, 反転フラグ);
94  }
95 
97  bool DrawRotate(const Point &座標, double 拡大率, double 角度, bool 反転フラグ = false) const override
98  {
99  return GetFrame()->DrawRotate(座標, 拡大率, 角度, 反転フラグ);
100  }
102  bool DrawRotateAxis(const Point &座標, const Point &回転軸座標, double 拡大率, double 角度, bool 反転フラグ = false) const override
103  {
104  return GetFrame()->DrawRotateAxis(座標, 回転軸座標, 拡大率, 角度, 反転フラグ);
105  }
107  bool DrawRotateAxis(const Point &座標, const Point &回転軸座標, double 拡大率X, double 拡大率Y, double 角度, bool 反転フラグ = false) const override
108  {
109  return GetFrame()->DrawRotateAxis(座標, 回転軸座標, 拡大率X, 拡大率Y, 角度, 反転フラグ);
110  }
111 
113  bool DrawPart(const Point &描画先座標, const Rect &描画元領域, bool 反転フラグ = false) const override
114  {
115  return GetFrame()->DrawPart(描画先座標, 描画元領域, 反転フラグ);
116  }
117  };
118 }
次のコマに進む
矩形を表す図形クラス.
Definition: Rect.h:22
bool DrawRotateAxis(const Point &座標, const Point &回転軸座標, double 拡大率, double 角度, bool 反転フラグ=false) const override
回転軸、角度、拡大率を指定して描画.
Definition: Image.h:244
bool DrawExtend(const Rect &描画領域, bool 反転フラグ=false) const override
指定矩形内に描画.
Definition: Image.h:201
bool DrawPart(const Point &描画先座標, const Rect &描画元領域, bool 反転フラグ=false) const override
指定した一部分を描画.
Definition: Image.h:268
Image * GetFrame() const
現在のコマを取得.
Definition: Anime.h:63
bool Update(double 経過フレーム=1)
カウンタの更新.
Definition: Anime.h:27
std::vector< Image * > imageS
保持するImage
Definition: ImagePack.h:20
bool Draw(const Point &座標, bool 反転フラグ=false) const override
指定座標に描画.
Definition: Anime.h:85
void SetFrame(int コマ数)
コマの位置を設定.
Definition: Anime.h:70
点を表す図形クラス.
Definition: Point.h:22
bool DrawPart(const Point &描画先座標, const Rect &描画元領域, bool 反転フラグ=false) const override
指定した一部分を描画.
Definition: Anime.h:113
bool DrawRotate(const Point &座標, double 拡大率, double 角度, bool 反転フラグ=false) const override
角度、拡大率を指定して描画.
Definition: Image.h:229
画像データを表すクラス.
Definition: Image.h:17
コマの進む向きをマイナスにしてから進む
bool DrawRotateAxis(const Point &座標, const Point &回転軸座標, double 拡大率X, double 拡大率Y, double 角度, bool 反転フラグ=false) const override
回転軸、角度、拡大率を縦横別に指定して描画.
Definition: Anime.h:107
bool DrawExtend(const Rect &描画領域, bool 反転フラグ=false) const override
指定矩形内に描画.
Definition: Anime.h:91
描画可能なクラスのインターフェース.
Definition: IDrawable.h:14
ImagePackにコマ毎の再生時間を追加したクラス.
Definition: Film.h:32
int GetSize() const
要素数を取得.
Definition: ImagePack.h:186
Filmに再生状態を付与したクラス.
Definition: Anime.h:11
コマの進む向きをプラスにしてから進む
Anime(const Film *再生する対象)
コンストラクタ.
Definition: Anime.h:21
このコマでアニメーションを停止する
bool DrawRotate(const Point &座標, double 拡大率, double 角度, bool 反転フラグ=false) const override
角度、拡大率を指定して描画.
Definition: Anime.h:97
bool Draw(const Point &座標, bool 反転フラグ=false) const override
指定座標に描画.
Definition: Image.h:181
bool DrawRotateAxis(const Point &座標, const Point &回転軸座標, double 拡大率, double 角度, bool 反転フラグ=false) const override
回転軸、角度、拡大率を指定して描画.
Definition: Anime.h:102