想让物体在发生碰撞的瞬间静止
使用了setDynamic()函数,最后各种报错
auto contactListener = EventListenerPhysicsContact::create();
contactListener->onContactBegin = =](PhysicsContact& contact) -> bool
{
return true;
};
contactListener->onContactPostSolve = =](PhysicsContact& contact, const PhysicsContactPostSolve& solve)
{
contact.getShapeA()->getBody()->setDynamic(false);
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(contactListener, this);
Aborting due to Chipmunk error: This operation cannot be done safely during a call to cpSpaceStep() or during a query. Put these calls into a post-step callback.
Failed condition: !space->locked
求大神讲解
