Je possède ce code qui me donne le temps de courir erreur dans la ligne:CreateFixture box2d avec b2FixtureDef donne pur appel de fonction virtuelle
body->CreateFixture(&boxDef)
im en utilisant cocos2d-x 2.1.5 avec box2d 2.2.1 dans les fenêtres
CCSprite *sprite = CCSprite::create(imageName.c_str());
this->addChild(sprite,1);
b2BodyDef bodyDef;
bodyDef.type = isStatic?b2_staticBody:b2_dynamicBody;
bodyDef.position.Set((position.x+sprite->getContentSize().width/2.0f)/PTM_RATIO,
(position.y+sprite->getContentSize().height/2.0f)/PTM_RATIO);
bodyDef.angle = CC_DEGREES_TO_RADIANS(rotation);
bodyDef.userData = sprite;
b2Body *body = world->CreateBody(&bodyDef);
b2FixtureDef boxDef;
if (isCircle)
{
b2CircleShape circle;
circle.m_radius = sprite->getContentSize().width/2.0f/PTM_RATIO;
boxDef.shape = &circle;
}
else
{
b2PolygonShape box;
box.SetAsBox(sprite->getContentSize().width/2.0f/PTM_RATIO, sprite->getContentSize().height/2.0f/PTM_RATIO);
boxDef.shape = &box;
}
if (isEnemy)
{
boxDef.userData = (void*)1;
enemies->insert(body);
}
boxDef.density = 0.5f;
body->CreateFixture(&boxDef) //<-- HERE IS THE RUN TIME ERROR
;
lorsque i déboguer le code box2d im obtenir à b2Fixture.cpp dans le procédé:
void b2Fixture::Create(b2BlockAllocator* allocator, b2Body* body, const b2FixtureDef* def)
dans la ligne:
m_shape = def->shape->Clone(allocator);
obtenir l'erreur d'exécution:
Appel de fonction virtuelle pure R6025
Merci à vous !!! aimez votre travail! – user63898