我正在研究 Space Invaders,在我的 Player 类中,我使用了一个名为 point 的结构的向量来存储火箭的坐标。出于某种原因,当我尝试在 .cpp 文件中使用它时,我得到了“rocketVector:未声明的标识符”。
有谁知道为什么?
我对 C++ 还是很陌生,我无法在谷歌上找到解决方案。它现在开始让我头疼了:)
谢谢你的帮助!
#include <windows.h>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <stdio.h>
#include <MMSystem.h>
using namespace std;
class Player
{
public:
Player(void);
~Player(void);
void drawRockets(ISprite *r);
vector<point> rocketVector;
};
播放器.cpp
void drawRockets(ISprite *r) {
// Draw appropriate number of rockets
for(int i = 0; i < rocketVector.size(); i++){
if( rocketVector[i].y < 0.0 ){
// Remove rockets off screen
rocketVector.erase(rocketVector.begin() + i);
}
else{
rocketVector[i].y -= 20;
r->draw(int(rocketVector[i].x), int(rocketVector[i].y));
}
}
}