SDXFrameWork 0.09 SDXFrameWork

- Main Page
- Related Pages
- Classes

All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Camera.h
1 #pragma once//©SDXFramework http://sourceforge.jp/projects/dxframework/
2 namespace SDX
3 {
5 enum class ChaseType
6 {
7 NormalChase,
8 Smooth,
9 XToY,
10 YToX,
11 Warp,
12 };
13
16 class Camera
17 {
18 private:
19 double x;
20 double y;
21 double zoom;
22
23 double forcusX;
24 double forcusY;
25 double forcusZ;
26
27 double speed;
28 double speedZ;
29
30 double centerX;
31 double centerY;
32
33 static Camera* cameraNow;
34
35 ChaseType chaseType;
36 public:
39 Camera(double 座標X , double 座標Y , double 拡大率):
40 x(座標X),
41 y(座標Y),
42 zoom(拡大率),
43 forcusX(座標X),
44 forcusY(座標Y),
45 forcusZ(拡大率),
46 speed(1),
47 speedZ(1),
48 centerX(座標X),
49 centerY(座標Y),
50 chaseType(ChaseType::Warp)
51 {};
52
54 static Camera* Now()
55 {
56 return cameraNow;
57 }
58
61 void SetActive()
62 {
63 cameraNow = this;
64 }
65
67 void SetCenter(double X座標 , double Y座標)
68 {
69 this->centerX = X座標;
70 this->centerY = Y座標;
71 }
72
74 double GetCenterX()
75 {
76 return this->centerX;
77 }
78
80 double GetCenterY()
81 {
82 return this->centerY;
83 }
84
86 void Set(double X座標 , double Y座標 ,double 拡大率)
87 {
88 this->x = X座標;
89 this->y = Y座標;
90 this->zoom = 拡大率;
91 }
92
94 void MoveForcus(double X座標 ,double Y座標)
95 {
96 this->forcusX += X座標;
97 this->forcusY += Y座標;
98 }
99
101 void SetForcus(double X座標 , double Y座標)
102 {
103 this->forcusX = X座標;
104 this->forcusY = Y座標;
105 }
106
108 void SetZoomForcus(double 拡大率)
109 {
110 this->forcusZ = 拡大率;
111 }
112
114 void SetSpeed(double 追跡速度)
115 {
116 this->speed = 追跡速度;
117 }
118
120 void SetZoomSpeed(double 拡大速度)
121 {
122 this->speedZ = 拡大速度;
123 }
124
126 double GetZoom()
127 {
128 return this->zoom;
129 }
130
132 void SetChaseType(ChaseType 追跡タイプ)
133 {
134 chaseType = 追跡タイプ;
135 }
136
138 void Update()
139 {
140 x = x/2 + forcusX/2;
141 y = y/2 + forcusY/2;
142 zoom = zoom/2 + forcusZ/2;
143 }
144
146 double TransX(double X座標変換前)
147 {
148 return centerX + ( X座標変換前 - this->x ) * zoom;
149 }
150
152 double TransY(double Y座標変換前)
153 {
154 return centerY + ( Y座標変換前 - this->y ) * zoom;
155 }
156
157 Point Trans(const Point &変換前座標)
158 {
159 return Point(centerX + ( 変換前座標.x - this->x ) * zoom , centerY + ( 変換前座標.y - this->y ) * zoom );
160 }
161 };
162 }
SDX::Camera::TransY
double TransY(double Y座標変換前)
カメラの位置と拡大率に応じてY座標を変換.
Definition: Camera.h:152
SDX::Camera::SetChaseType
void SetChaseType(ChaseType 追跡タイプ)
追跡方法を設定.
Definition: Camera.h:132
SDX::Camera::SetCenter
void SetCenter(double X座標, double Y座標)
カメラの焦点を設定.
Definition: Camera.h:67
SDX::Camera::TransX
double TransX(double X座標変換前)
カメラの位置と拡大率に応じてX座標を変換.
Definition: Camera.h:146
SDX::Camera::Update
void Update()
追跡方法や速度に応じてカメラ位置の更新.
Definition: Camera.h:138
SDX::Camera::SetForcus
void SetForcus(double X座標, double Y座標)
移動目標座標を設定.
Definition: Camera.h:101
SDX::Camera::MoveForcus
void MoveForcus(double X座標, double Y座標)
移動目標座標を相対移動.
Definition: Camera.h:94
SDX::ChaseType
ChaseType
カメラの追跡方式.
Definition: Camera.h:5
SDX::Camera::SetZoomForcus
void SetZoomForcus(double 拡大率)
拡大目標をセット.
Definition: Camera.h:108
SDX::ChaseType::XToY
横移動してから縦移動する
SDX::ChaseType::NormalChase
普通に追跡
SDX::Point
点を表す図形クラス.
Definition: Shape.h:129
SDX::Camera::SetActive
void SetActive()
カメラをアクティブにする.
Definition: Camera.h:61
SDX::ChaseType::Smooth
加減速しつつ追跡
SDX::Camera::Now
static Camera * Now()
アクティブなカメラを取得.
Definition: Camera.h:54
SDX::ChaseType::Warp
一瞬で移動する
SDX::Camera::GetZoom
double GetZoom()
拡大率を取得.
Definition: Camera.h:126
SDX::Camera::GetCenterX
double GetCenterX()
焦点のX座標を取得.
Definition: Camera.h:74
SDX::Camera::Camera
Camera(double 座標X, double 座標Y, double 拡大率)
カメラの作成.
Definition: Camera.h:39
SDX::Camera::Set
void Set(double X座標, double Y座標, double 拡大率)
位置と倍率を設定.
Definition: Camera.h:86
SDX::Camera
2D用に座標変換を行うカメラを表すクラス.
Definition: Camera.h:16
SDX::Camera::SetZoomSpeed
void SetZoomSpeed(double 拡大速度)
拡大応答速度を設定.
Definition: Camera.h:120
SDX::ChaseType::YToX
縦移動してから横移動する
SDX::Camera::SetSpeed
void SetSpeed(double 追跡速度)
追跡速度を設定.
Definition: Camera.h:114
SDX::Camera::GetCenterY
double GetCenterY()
焦点のY座標を取得.
Definition: Camera.h:80