This error occurs because the ShapeDef is on the shape. Do not create it in a field at the same level as the ShapeDef when you create the Shape. For example, this throws an exception:
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;
}
can be written to avoid exceptions:
b2CircleShape circle;
b2PolygonShape box;
if (isCircle)
{
circle.m_radius = sprite->getContentSize().width/2.0f/PTM_RATIO;
boxDef.shape = &circle;
}
else
{
box.SetAsBox(sprite->getContentSize().width/2.0f/PTM_RATIO, sprite->getContentSize().height/2.0f/PTM_RATIO);
boxDef.shape = &box;
}
Read More:
- Drawing function of GLUT
- Tensorflow image random_ There seems to be something wrong with the shift function
- JavaScript to achieve image rotation effect
- Python opencv (3) get image size
- Simple license plate recognition based on Halcon
- Android get screen width and height and get control width and height
- Android gets the height and width of the screen
- Several ways to center elements horizontally and vertically
- Android layout: layer layout
- JS Mobile Page to determine whether it is iPhone X, and then set the corresponding height of the element?
- CSS: several ways to center the box vertically and horizontally
- How to center the box horizontally and vertically in HTML
- After IOS upgrade, the time control selected by the wheel will be invalid, uidatepicker
- Problem solving – vs debugging window flash solution
- Converting PDF file to JPG image in Ubuntu
- Tensorflow: How to use expand_Dim() to add dimensions
- Invalidation of margin top property of nested box in CSS style box
- Several common methods of inserting pictures into latex documents
- Android solves the gliding problem of EditText