我可以在Box2d上找到的每个教程都说这样做是为了迭代一个世界中的实体:
std::set<b2Body*>toDestroy; //ERROR
for(b2Body *b = world->GetBodyList(); b; b=b->GetNext()) {
if (b->GetUserData() != NULL) {
CCSprite *sprite = (__bridge CCSprite *)b->GetUserData();
if (sprite.tag == kWhateverTag) {
CCSprite *spriteData = (__bridge CCSprite *)b->GetUserData();
spriteData.position = ccp(b->GetPosition().x * PTM_RATIO,
b->GetPosition().y * PTM_RATIO);
spriteData.rotation = -1 * CC_RADIANS_TO_DEGREES(b->GetAngle());
if (self.shouldDestroy) {
toDestroy.insert(b); //ERROR
}
}
}
}
但是我收到错误"Use of undeclared identifier 'toDestroy'; did you mean 'tgaDestroy'?
我需要做些什么才能摆脱错误?
答案 0 :(得分:0)
这清除了错误:
#import <vector>
#import <set>
#import <algorithm>