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:
- Solution of Prophet error reporting when installing R package in Kubuntu virtual machine environment
- Invalidation of margin top property of nested box in CSS style box
- How to debug stored procedure/function in TOAD
- Vboxnetadp6.sys file required for virtual box error
- R ggplot Error in .Call.graphics(C_palette2, .Call(C_palette2, NULL)): invalid graphics state
- Call to undefined function mysql_ Connect() solution summary
- Use of rep function in R
- R language – error analysis – error in Call.graphics (C_ palette2, .Call(C_ palette2, NULL)) : invalid graphics state
- R:Error : .onLoad failed in loadNamespace() for ‘rJava’, details: call: dyn.load(file, DLLpa
- Solving the problem of saving object set by save() function in R language
- The solution to frequently pop up “cannot find a valid baseurl for repo” error prompt box in CentOS 6.7
- Fatal error: Call to a member function bind_param() on a non-object in
- PHP Fatal error: Call to a member function query() on a non-object in
- Vue element UI uses this. $notify is not a function problem resolution using the notification box
- PY3 install box2d PY
- How to center the box horizontally and vertically in HTML
- The solution of “error in NLS loop more than 50” in R language
- R note for Bioinfo: the column for the select call is undefined
- Cannot call the same level library solution in pychar
- unity 3D:Virtual Reality SDK Oculus failed to initialize.