cocos2d-x 2.2 wp8 issues with Box2D

Hi guys,

I create a game, ios and android work both fine, so I decide to convert to wp8, the strange thing is THESE code always crush in emulator.

for (b2Body* b = world->GetBodyList(); b; b = b->GetNext())
{
	if (b && b->GetUserData() != NULL)
	{
		CCSprite *spr = (CCSprite*)b->GetUserData();
        
        if (spr != NULL) {
            if (spr->getPosition().x < -spr->getContentSize().width)
            {
                world->DestroyBody(b);
                
                // remove self
                spr->removeFromParentAndCleanup(true);
            }
       }
    }

When I want to loop all the b2Body in the world, always get NULL ‘b’, but it works fine in iOS and android. Does any body have the same problems?

I don’t know if it’s the cause of the crash, but you should not do:

DestroyBody(b)

and then do:

b->GetNext()

because b is now invalid.