質問編集履歴
2
提示コードを修正しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,12 +1,19 @@
|
|
1
|
-
提示コードのコメント部で囲ってあるコードですがなぜ以下のエラーが発生するのでしょうか?
|
1
|
+
提示コードのコメント部で囲ってあるコードですがなぜ以下のエラーが発生するのでしょうか? エラーが4件起きているのですが何が悪いのか理解出来ません。
|
2
2
|
|
3
3
|
|
4
|
+
エラー1「 "std::array<std::array<Stage::MapChip, 10Ui64>, 10Ui64>" から "std::array<std::array<MapChip, 10Ui64>, 10Ui64>" への適切なユーザー定義変換が存在しません 」
|
4
5
|
|
5
|
-
エラ「
|
6
|
-
C2079 'std::array<MapChip,10>::_Elems' が 未定義の struct 'MapChip' で使用しています。
|
7
|
-
」
|
8
6
|
|
7
|
+
エラー2「 'Stage::getMap': 再定義されています。異なる基本型です。 」
|
9
8
|
|
9
|
+
|
10
|
+
エラー3「 'std::array<std::array<MapChip,10>,10> Stage::getMap(void)': オーバーロード関数は、'std::array<std::array<Stage::MapChip,10>,10> Stage::getMap(void)' と戻り値の型のみが異なります。 」
|
11
|
+
|
12
|
+
|
13
|
+
エラー4「 宣言に "std::array<std::array<Stage::MapChip, 10Ui64>, 10Ui64> Stage::getMap()" 」
|
14
|
+
|
15
|
+
|
16
|
+
|
10
17
|
```cpp
|
11
18
|
#ifndef ___STAGE_HPP_
|
12
19
|
#define ___STAGE_HPP_
|
@@ -21,66 +28,57 @@
|
|
21
28
|
#include <algorithm>
|
22
29
|
|
23
30
|
// 前方宣言
|
24
|
-
struct DrawUV;
|
25
31
|
|
26
|
-
typedef struct MapChip MapChip;
|
27
|
-
|
28
32
|
class Stage : public Actor_2D
|
29
33
|
{
|
30
34
|
public:
|
35
|
+
|
36
|
+
|
37
|
+
|
31
38
|
Stage(class Game* g, const char* fileName); //コンストラクタ
|
32
39
|
~Stage(); //デストラクタ
|
33
40
|
|
34
41
|
void Update() override; //更新
|
35
42
|
void Draw() override; //描画更新
|
36
43
|
|
37
|
-
///////////////////////////////////////////////////////////////////////////////////
|
38
|
-
std::array< std::array<MapChip, 10>, 10> getMap();
|
39
|
-
///////////////////////////////////////////////////////////////////////////////////
|
40
44
|
|
45
|
+
// 描画UV座標
|
41
|
-
|
46
|
+
typedef struct DrawUV
|
47
|
+
{
|
48
|
+
glm::vec2 start; //ここから
|
49
|
+
glm::vec2 end; //ここまで
|
42
50
|
|
51
|
+
}DrawUV;
|
52
|
+
|
43
53
|
// マップチップの種別
|
44
54
|
typedef enum MapChipType
|
45
55
|
{
|
46
56
|
Block, //破壊 可能
|
47
57
|
notBreak_Block, //破壊 不可
|
48
58
|
Item, //アイテム
|
49
|
-
|
59
|
+
|
50
60
|
Invalid, //無効
|
51
61
|
} MapChipType;
|
52
62
|
|
53
63
|
|
54
|
-
// 描画UV座標
|
55
|
-
typedef struct DrawUV
|
56
|
-
{
|
57
|
-
glm::vec2 start; //ここから
|
58
|
-
glm::vec2 end; //ここまで
|
59
|
-
|
60
|
-
}DrawUV;
|
61
|
-
|
62
|
-
|
63
|
-
// マップチップの情報
|
64
|
+
// マップチップの情報
|
64
65
|
typedef struct MapChip
|
65
66
|
{
|
66
67
|
MapChipType type; //種類
|
67
68
|
glm::vec2 mPosition; //座標
|
68
69
|
DrawUV UV; //描画範囲
|
69
70
|
}MapChip;
|
71
|
+
////////////////////////////////////////////////////////////////////////////////////////
|
72
|
+
std::array< std::array<MapChip, 10>, 10> getMap(); //マップセル取得
|
73
|
+
///////////////////////////////////////////////////////////////////////////////////////
|
74
|
+
private:
|
70
75
|
|
71
|
-
|
72
|
-
|
73
76
|
std::shared_ptr<Sprite> mSprite; //スプライトクラス
|
74
77
|
|
75
78
|
std::array< std::array<MapChip,10>,10> mMap; //マップデータ
|
76
79
|
|
77
80
|
glm::vec2 blockUV; //ブロックのUV座標
|
78
81
|
glm::vec2 notBreak_blockUV; //固定ブロックのUV座標
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
82
|
};
|
85
83
|
|
86
84
|
#endif;
|
@@ -92,7 +90,11 @@
|
|
92
90
|
#include "../../Header/Actor_2D.hpp"
|
93
91
|
|
94
92
|
#include "../../Header/Game.hpp"
|
93
|
+
|
94
|
+
#include <vector>
|
95
95
|
#include <array>
|
96
|
+
#include <iostream>
|
97
|
+
#include <algorithm>
|
96
98
|
|
97
99
|
|
98
100
|
struct MapChip;
|
@@ -123,9 +125,6 @@
|
|
123
125
|
const int width = -(int)(SCREEN_WIDTH / 2); //
|
124
126
|
const int height = (int)(SCREEN_HEIGHT / 2); //
|
125
127
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
128
|
// 座標を設定
|
130
129
|
for (int y = 0; y < mMap.size(); y++)
|
131
130
|
{
|
@@ -144,19 +143,6 @@
|
|
144
143
|
}
|
145
144
|
}
|
146
145
|
|
147
|
-
|
148
|
-
|
149
|
-
// マップを初期化
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
//mMap.at(0).at(1) = MapChipType::Block;
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
146
|
}
|
161
147
|
|
162
148
|
// 描画
|
@@ -166,17 +152,19 @@
|
|
166
152
|
{
|
167
153
|
for (int x = 0; x < mMap.at(y).size(); x++)
|
168
154
|
{
|
155
|
+
|
156
|
+
|
169
157
|
mSprite->DrawGraph(mMap.at(y).at(x).mPosition, mMap.at(y).at(x).UV.start, mMap.at(y).at(x).UV.end);
|
170
158
|
}
|
171
159
|
}
|
172
160
|
|
173
161
|
}
|
174
|
-
///////////////////////////////////////////////////////////////////
|
162
|
+
//////////////////////////////////////////////////////////////////////////////////
|
175
|
-
std::array< std::array<MapChip, 10>, 10>
|
163
|
+
std::array< std::array<MapChip, 10>, 10> Stage::getMap()
|
176
164
|
{
|
177
165
|
return mMap;
|
178
166
|
}
|
179
|
-
///////////////////////////////////////////////////////////////////
|
167
|
+
//////////////////////////////////////////////////////////////////////////////////
|
180
168
|
|
181
169
|
// 更新
|
182
170
|
void Stage::Update()
|
1
タイトルと文章を修正しました。
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
構造体が未定義と表示される原因と対処法が知りたい。
|
body
CHANGED
@@ -1,15 +1,194 @@
|
|
1
|
-
提示コードで
|
1
|
+
提示コードのコメント部で囲ってあるコードですがなぜ以下のエラーが発生するのでしょうか? 上の方でしっかり前方宣言されているはずですが理由がわかりません。
|
2
2
|
|
3
3
|
|
4
|
+
|
5
|
+
エラ「
|
6
|
+
C2079 'std::array<MapChip,10>::_Elems' が 未定義の struct 'MapChip' で使用しています。
|
7
|
+
」
|
8
|
+
|
9
|
+
|
4
10
|
```cpp
|
11
|
+
#ifndef ___STAGE_HPP_
|
5
|
-
|
12
|
+
#define ___STAGE_HPP_
|
6
13
|
|
14
|
+
#include "../Actor_2D.hpp"
|
15
|
+
#include "Block.hpp"
|
16
|
+
#include "../Game.hpp"
|
7
17
|
|
18
|
+
#include <vector>
|
19
|
+
#include <array>
|
20
|
+
#include <iostream>
|
21
|
+
#include <algorithm>
|
22
|
+
|
23
|
+
// 前方宣言
|
24
|
+
struct DrawUV;
|
25
|
+
|
8
|
-
|
26
|
+
typedef struct MapChip MapChip;
|
27
|
+
|
28
|
+
class Stage : public Actor_2D
|
9
29
|
{
|
30
|
+
public:
|
31
|
+
Stage(class Game* g, const char* fileName); //コンストラクタ
|
32
|
+
~Stage(); //デストラクタ
|
33
|
+
|
34
|
+
void Update() override; //更新
|
35
|
+
void Draw() override; //描画更新
|
36
|
+
|
37
|
+
///////////////////////////////////////////////////////////////////////////////////
|
38
|
+
std::array< std::array<MapChip, 10>, 10> getMap();
|
39
|
+
///////////////////////////////////////////////////////////////////////////////////
|
40
|
+
|
41
|
+
private:
|
42
|
+
|
43
|
+
// マップチップの種別
|
44
|
+
typedef enum MapChipType
|
45
|
+
{
|
46
|
+
Block, //破壊 可能
|
47
|
+
notBreak_Block, //破壊 不可
|
48
|
+
Item, //アイテム
|
49
|
+
|
50
|
+
Invalid, //無効
|
51
|
+
} MapChipType;
|
52
|
+
|
53
|
+
|
54
|
+
// 描画UV座標
|
55
|
+
typedef struct DrawUV
|
56
|
+
{
|
57
|
+
glm::vec2 start; //ここから
|
58
|
+
glm::vec2 end; //ここまで
|
59
|
+
|
60
|
+
}DrawUV;
|
61
|
+
|
62
|
+
|
63
|
+
// マップチップの情報
|
64
|
+
typedef struct MapChip
|
65
|
+
{
|
66
|
+
MapChipType type; //種類
|
67
|
+
glm::vec2 mPosition; //座標
|
68
|
+
DrawUV UV; //描画範囲
|
69
|
+
}MapChip;
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
std::shared_ptr<Sprite> mSprite; //スプライトクラス
|
74
|
+
|
75
|
+
std::array< std::array<MapChip,10>,10> mMap; //マップデータ
|
76
|
+
|
77
|
+
glm::vec2 blockUV; //ブロックのUV座標
|
78
|
+
glm::vec2 notBreak_blockUV; //固定ブロックのUV座標
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
};
|
85
|
+
|
86
|
+
#endif;
|
87
|
+
|
88
|
+
```
|
89
|
+
|
90
|
+
```cpp
|
91
|
+
#include "../../Header/Game/Stage.hpp"
|
92
|
+
#include "../../Header/Actor_2D.hpp"
|
93
|
+
|
94
|
+
#include "../../Header/Game.hpp"
|
95
|
+
#include <array>
|
96
|
+
|
97
|
+
|
98
|
+
struct MapChip;
|
99
|
+
|
100
|
+
// コンストラクタ
|
101
|
+
Stage::Stage(class Game* g, const char* fileName) : Actor_2D()
|
102
|
+
{
|
103
|
+
Owner = g; // Game クラス
|
104
|
+
mSprite = std::make_shared<Sprite>(Owner,fileName); //スプライトクラス
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
// マップ配列を初期化
|
111
|
+
MapChip m{
|
112
|
+
MapChipType::Invalid, //マップの種類
|
113
|
+
glm::vec2(0,0), //座標
|
114
|
+
DrawUV{ glm::vec2(0,0),glm::vec2(0,0)} //描画UV座標
|
115
|
+
};
|
116
|
+
|
117
|
+
|
118
|
+
for (int i = 0; i < mMap.size(); i++){
|
119
|
+
std::fill(mMap.at(i).begin(), mMap.at(i).end(), m);
|
120
|
+
}
|
121
|
+
|
122
|
+
//画面の左上
|
123
|
+
const int width = -(int)(SCREEN_WIDTH / 2); //
|
124
|
+
const int height = (int)(SCREEN_HEIGHT / 2); //
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
// 座標を設定
|
130
|
+
for (int y = 0; y < mMap.size(); y++)
|
131
|
+
{
|
132
|
+
for (int x = 0; x < mMap.at(y).size(); x++)
|
133
|
+
{
|
134
|
+
//
|
135
|
+
mMap.at(y).at(x).mPosition.x = (float) (width + (CELL * x));
|
136
|
+
mMap.at(y).at(x).mPosition.y = (float) (height - (CELL * y));
|
137
|
+
|
138
|
+
mMap.at(y).at(x).type = MapChipType::Block; //
|
139
|
+
|
140
|
+
//
|
141
|
+
mMap.at(y).at(x).UV.start = glm::vec2(0, 0);
|
142
|
+
mMap.at(y).at(x).UV.start = glm::vec2(CELL, CELL);
|
143
|
+
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
// マップを初期化
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
//mMap.at(0).at(1) = MapChipType::Block;
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
}
|
161
|
+
|
162
|
+
// 描画
|
163
|
+
void Stage::Draw()
|
164
|
+
{
|
165
|
+
for (int y = 0; y < mMap.size(); y++)
|
166
|
+
{
|
167
|
+
for (int x = 0; x < mMap.at(y).size(); x++)
|
168
|
+
{
|
169
|
+
mSprite->DrawGraph(mMap.at(y).at(x).mPosition, mMap.at(y).at(x).UV.start, mMap.at(y).at(x).UV.end);
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
}
|
174
|
+
///////////////////////////////////////////////////////////////////
|
175
|
+
std::array< std::array<MapChip, 10>, 10> Stage::getMap()
|
176
|
+
{
|
10
177
|
return mMap;
|
11
178
|
}
|
179
|
+
///////////////////////////////////////////////////////////////////
|
12
180
|
|
181
|
+
// 更新
|
182
|
+
void Stage::Update()
|
183
|
+
{
|
13
184
|
|
185
|
+
}
|
14
186
|
|
187
|
+
|
188
|
+
|
189
|
+
// デストラクタ
|
190
|
+
Stage::~Stage()
|
191
|
+
{
|
192
|
+
|
193
|
+
}
|
15
194
|
```
|