I made a simple obstacle for a game:
And i get this error at rutime:
The point was to make the shape of this square:

Code:
class Square{
public:
sf::Image Squareskin;
sf::Sprite SquareSprite;
b2PolygonShape SquareShape;
b2Vec2 vertex[8];
int32 vertexcount;
b2BodyDef SquareDef;
b2FixtureDef SquareFixture;
b2Body *SquareBody;
Square()
{
Squareskin.LoadFromFile("square.tga");
Squareskin.SetSmooth(true);
SquareSprite.SetImage(Squareskin);
SquareSprite.SetCenter(Squareskin.GetWidth()/2,Squareskin.GetHeight()/2);
SquareSprite.SetScale(0.05,0.05);
vertexcount=8;
vertex[0].Set(0,7);
vertex[1].Set(0,30);
vertex[2].Set(7,37);
vertex[3].Set(30,37);
vertex[4].Set(37,30);
vertex[5].Set(37,7);
vertex[6].Set(30,0);
vertex[7].Set(7,0);
SquareShape.Set(vertex,vertexcount);
SquareDef.type=b2_staticBody;
SquareFixture.shape=&SquareShape;
SquareFixture.friction=0.3;
SquareBody=World.CreateBody(&SquareDef);
SquareBody->CreateFixture(&SquareFixture);
}
void SetPosition(float x,float y)
{
SquareBody->SetTransform(b2Vec2(x,y),SquareBody->GetAngle());
}
void SetPosition(b2Vec2 &pos)
{
SquareBody->SetTransform(pos,SquareBody->GetAngle());
}
void Draw()
{
SquareSprite.SetPosition(SquareBody->GetPosition().x,SquareBody->GetPosition().y);
SquareSprite.SetRotation(-SquareBody->GetAngle()*(180/pi));
GameW.Draw(SquareSprite);
}
};
public:
sf::Image Squareskin;
sf::Sprite SquareSprite;
b2PolygonShape SquareShape;
b2Vec2 vertex[8];
int32 vertexcount;
b2BodyDef SquareDef;
b2FixtureDef SquareFixture;
b2Body *SquareBody;
Square()
{
Squareskin.LoadFromFile("square.tga");
Squareskin.SetSmooth(true);
SquareSprite.SetImage(Squareskin);
SquareSprite.SetCenter(Squareskin.GetWidth()/2,Squareskin.GetHeight()/2);
SquareSprite.SetScale(0.05,0.05);
vertexcount=8;
vertex[0].Set(0,7);
vertex[1].Set(0,30);
vertex[2].Set(7,37);
vertex[3].Set(30,37);
vertex[4].Set(37,30);
vertex[5].Set(37,7);
vertex[6].Set(30,0);
vertex[7].Set(7,0);
SquareShape.Set(vertex,vertexcount);
SquareDef.type=b2_staticBody;
SquareFixture.shape=&SquareShape;
SquareFixture.friction=0.3;
SquareBody=World.CreateBody(&SquareDef);
SquareBody->CreateFixture(&SquareFixture);
}
void SetPosition(float x,float y)
{
SquareBody->SetTransform(b2Vec2(x,y),SquareBody->GetAngle());
}
void SetPosition(b2Vec2 &pos)
{
SquareBody->SetTransform(pos,SquareBody->GetAngle());
}
void Draw()
{
SquareSprite.SetPosition(SquareBody->GetPosition().x,SquareBody->GetPosition().y);
SquareSprite.SetRotation(-SquareBody->GetAngle()*(180/pi));
GameW.Draw(SquareSprite);
}
};
And i get this error at rutime:
Code:
Assertion failed: area > 1.19209289550781250000e-7F, file D:\Box2D\Box2D\Collisi
on\Shapes\b2PolygonShape.cpp, line 127
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Process returned 3 (0x3) execution time : 0.750 s
Press any key to continue.
on\Shapes\b2PolygonShape.cpp, line 127
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Process returned 3 (0x3) execution time : 0.750 s
Press any key to continue.
The point was to make the shape of this square:
