SDXFrameWork
0.11
SDXFrameWork
Main Page
Related Pages
Classes
All
Classes
Namespaces
Functions
Variables
Enumerations
Enumerator
Pages
Multimedia
Touch.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 <Multimedia/Key.h>
6
#include <Multimedia/Window.h>
7
8
namespace
SDX
9
{
12
class
Touch
13
{
14
friend
class
Input
;
15
private
:
16
MONO_STATE(
Touch
)
17
18
bool
press =
false
;
19
double
xBuffer;
20
double
yBuffer;
21
22
void
Position(
double
X座標,
double
Y座標)
23
{
24
const
double
aspA =
Window::activeWindow
->aspect;
25
const
double
aspB = (double)
Window::GetWidth
() /
Window::GetHeight
();
26
27
if
(aspA == aspB)
28
{
29
xBuffer = int(X座標 *
Window::GetWidth
());
30
yBuffer = int(Y座標 *
Window::GetHeight
());
31
}
32
else
if
(aspA > aspB){
33
//横が余る
34
double
rate = aspA / aspB;
35
double
pos = (X座標 - (rate - 1) / rate / 2) * rate;
36
xBuffer = int(pos *
Window::GetWidth
());
37
yBuffer = int(Y座標 *
Window::GetHeight
());
38
}
39
else
{
40
//上が余る
41
double
rate = aspB / aspA;
42
double
pos = (Y座標 - (rate - 1) / rate / 2) * rate;
43
xBuffer = int(X座標 *
Window::GetWidth
());
44
yBuffer = int(pos *
Window::GetHeight
());
45
}
46
}
47
48
public
:
49
double
x
= 0;
50
double
y
= 0;
51
52
double
moveX
= 0;
53
double
moveY
= 0;
54
55
bool
on
=
false
;
56
bool
off
=
false
;
57
bool
hold
=
false
;
58
59
unsigned
int
holdCount
= 0;
60
62
void
Update
()
63
{
64
on
= (!
hold
&& press);
65
off
= (
hold
&& !press);
66
67
hold
= press;
68
if
(press)
69
{
70
++
holdCount
;
71
}
72
else
73
{
74
holdCount
= 0;
75
}
76
77
if
(!
on
)
78
{
79
moveX
= xBuffer -
x
;
80
moveY
= yBuffer -
y
;
81
}
82
else
83
{
84
moveX
= 0;
85
moveY
= 0;
86
}
87
88
x
= xBuffer;
89
y
= yBuffer;
90
}
91
93
void
Reset
()
94
{
95
x
= 0;
96
y
= 0;
97
98
moveX
= 0;
99
moveY
= 0;
100
101
press =
false
;
102
103
on
=
false
;
104
off
=
false
;
105
hold
=
false
;
106
holdCount
= 0;
107
}
108
109
};
110
}
SDX::Window::GetWidth
static int GetWidth()
ウィンドウ幅の取得.
Definition:
Window.h:58
SDX::Window::GetHeight
static int GetHeight()
ウィンドウ高さの取得.
Definition:
Window.h:64
SDX::Touch::moveX
double moveX
前回更新時からの移動量
Definition:
Touch.h:52
SDX::Touch::hold
bool hold
タッチしている間は true
Definition:
Touch.h:57
SDX::Touch::y
double y
タッチしている座標
Definition:
Touch.h:50
SDX::Touch::off
bool off
指を離した直後は true
Definition:
Touch.h:56
SDX::Touch::holdCount
unsigned int holdCount
押されている時間
Definition:
Touch.h:59
SDX::Touch::Reset
void Reset()
状態のリセット.
Definition:
Touch.h:93
SDX::Touch::moveY
double moveY
前回更新時からの移動量
Definition:
Touch.h:53
SDX::Touch::x
double x
タッチしている座標
Definition:
Touch.h:49
SDX::Input
キーやマウスによる入力をまとめて管理するクラス.
Definition:
Input.h:17
SDX::Touch::on
bool on
タッチされた直後は true
Definition:
Touch.h:55
SDX::Touch::Update
void Update()
状態の更新.
Definition:
Touch.h:62
SDX::Touch
タッチ操作.
Definition:
Touch.h:12
SDX::Window::activeWindow
static SubWindow * activeWindow
現在アクティブなウィンドウ
Definition:
Window.h:24
Generated on Mon Jan 26 2015 21:49:55 for SDXFrameWork by
1.8.7