0

我可以在 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'?

我需要做什么才能摆脱错误?

4

1 回答 1

0

This clears up the errors:

#import <vector>
#import <set>
#import <algorithm>
于 2013-03-05T18:47:36.997 回答