我用 .game 制作游戏cocos2d + box2d
效果很好,但是玩了一段时间后,我的 b2world 挂了(地线在 drawDebug 模式下消失了),我的一些 b2bodies 属性变成了NAN
。(我不知道我应该在这里粘贴什么代码!:( )
这段代码有问题吗??
std::vector<b2Body *>toDestroy;
//Iterate over the bodies in the physics world
for (b2Body* b = world->GetBodyList(); b; b = b->GetNext())
{
if (b->GetUserData() != NULL) {
//Synchronize the AtlasSprites position and rotation with the corresponding body
CCSprite *myActor = (CCSprite*)b->GetUserData();
myActor.position = CGPointMake( b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO);
myActor.rotation = -1 * CC_RADIANS_TO_DEGREES(b->GetAngle());
if(myActor && myActor.tag==5){
if([myActor opacity]==0){
toDestroy.push_back(b);
}
}
}
}