DXフレームワーク　リファレンス・マニュアル 0.01 DXフレームワークのリファレンスです。詳細は公式wiki

- メインページ
- 関連ページ
- クラス
- ファイル

- ファイル一覧

Mask.h
1 #pragma once
2 #include<DxLib.h>
3 #include<vector>
4 #define NULL_HANDLE -1
5
6 namespace DXFW
7 {
11 enum class TransMode
12 {
13 TransNone = DX_MASKTRANS_NONE,
14 TransBlack = DX_MASKTRANS_BLACK,
15 TransWhite = DX_MASKTRANS_WHITE
16 };
17
33 class Mask
34 {
35 friend class MaskPack;
36
37 private:
38 int handle;
39 static bool isCreateScreen;
40 static bool isUseScreen;
41 unsigned char *data;
42 public:
43 Mask(void)
44 {
45 this->handle = NULL_HANDLE;
46 }
47
48 Mask(const char *ファイル名)
49 {
50 handle = DxLib::LoadMask(ファイル名);
51 }
52
53 Mask(int w,int h)
54 {
55 this->handle = DxLib::MakeMask(w,h);
56 }
57
58 int Load(const char *ファイル名)
59 {
60 if( this->handle != NULL_HANDLE )DxLib::DeleteMask( this->handle );
61 return handle = DxLib::LoadMask(ファイル名);
62 }
63
64 bool Release()
65 {
66 return !DxLib::DeleteMask( this->handle );
67 }
68
69 bool Draw(int x,int y,TransMode transMode)
70 {
71 return !DxLib::DrawMask( x , y , this->handle , (int)transMode );
72 }
73
74 bool DrawFill(int x1,int y1,int x2,int y2)
75 {
76 return !DxLib::DrawFillMask( x1 , y1 , x2 , y2 , this->handle );
77 }
78
79 bool FillScreen(bool isWhite)
80 {
81 return !DxLib::FillMaskScreen( isWhite );
82 }
83
84 int GetWidth()
85 {
86 int w,h;
87 DxLib::GetMaskSize( &w , & h , this->handle );
88 return w;
89 }
90
91 int GetHeight()
92 {
93 int w,h;
94 DxLib::GetMaskSize( &w , & h , this->handle );
95 return h;
96 }
97
98 bool SetData(int w , int h ,unsigned char *maskdata)
99 {
100 int w2,h2;
101 DxLib::GetMaskSize( &w2 , & h2 , this->handle );
102 if( w != w2 || h != h2 ) return false;
103 return !DxLib::SetDataToMask( w , h , maskdata , this->handle );
104 }
105
106 static bool DrawDirect(int x,int y,int w,int h,unsigned char *maskData,TransMode transMode)
107 {
108 return !DxLib::DrawMaskToDirectData( x , y , w , h , maskData , (int)transMode);
109 }
110
111 static bool DrawFillDirect(int x1,int y1,int x2,int y2,int w,int h,unsigned char *maskData)
112 {
113 return !DxLib::DrawFillMaskToDirectData( x1 , y1 , x2 , y2 , w , h , maskData );
114 }
115
116 static bool CreateScreen()
117 {
118 Mask::isCreateScreen = true;
119 Mask::isUseScreen = true;
120 return !DxLib::CreateMaskScreen();
121 }
122
123 static bool DeleteScreen()
124 {
125 Mask::isCreateScreen = false;
126 return !DxLib::DeleteMaskScreen();
127 }
128
129 static bool SetUseScreen(bool isUseble)
130 {
131 Mask::isUseScreen = isUseble;
132 return !DxLib::SetUseMaskScreenFlag( isUseble );
133 }
134
135 };
136
152 class MaskPack
153 {
154 private:
155 Mask *part;
156 int size;
157 public:
158 MaskPack();
159
160 MaskPack::MaskPack(char *ファイル名,int allNum,int xNum,int yNum,int xSize,int ySize)
161 {
162 int *buf = new int[allNum];
163
164 this->part = new Mask[allNum];
165
166 DxLib::LoadDivMask(ファイル名,allNum,xNum,yNum,xSize,ySize,buf);
167
168 for(int i=0;i<allNum;i++)
169 {
170 this->part[i].handle = buf[i];
171 }
172
173 size = allNum;
174
175 delete [] buf;
176 }
177
178 bool Load(char *ファイル名,int allNum,int xNum,int yNum,int xSize,int ySize)
179 {
180 if( size > 0 ) delete [] this->part;
181 int *buf = new int[allNum];
182
183 this->part = new Mask[allNum];
184
185 bool ok = !DxLib::LoadDivMask(ファイル名,allNum,xNum,yNum,xSize,ySize,buf);
186
187 for(int i=0;i<allNum;i++)
188 {
189 this->part[i].handle = buf[i];
190 }
191
192 size = allNum;
193
194 delete [] buf;
195
196 return ok;
197 }
198
199 bool Release()
200 {
201 for(int i=0;i<size;i++)
202 {
203 DxLib::DeleteMask( this->part[i].handle );
204 }
205 if( size > 0 ) delete [] this->part;
206 return true;
207 }
208
209 Mask& operator[](int index)
210 {
211 return part[index];
212 }
213 };
214 }
DXFW::TransMode
TransMode
説明
Definition: Mask.h:11
DXFW::Mask
Definition: Mask.h:33
DXFW::MaskPack
Definition: Mask.h:152