当前位置: 首页>>代码示例>>C++>>正文


C++ PhysicsContact::setEventCode方法代码示例

本文整理汇总了C++中PhysicsContact::setEventCode方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsContact::setEventCode方法的具体用法?C++ PhysicsContact::setEventCode怎么用?C++ PhysicsContact::setEventCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhysicsContact的用法示例。


在下文中一共展示了PhysicsContact::setEventCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: collisionBeginCallback

bool PhysicsWorld::collisionBeginCallback(PhysicsContact& contact)
{
    bool ret = true;
    
    PhysicsShape* shapeA = contact.getShapeA();
    PhysicsShape* shapeB = contact.getShapeB();
    PhysicsBody* bodyA = shapeA->getBody();
    PhysicsBody* bodyB = shapeB->getBody();
    std::vector<PhysicsJoint*> jointsA = bodyA->getJoints();
    
    // check the joint is collision enable or not
    for (PhysicsJoint* joint : jointsA)
    {
        if (std::find(_joints.begin(), _joints.end(), joint) == _joints.end())
        {
            continue;
        }
        
        if (!joint->isCollisionEnabled())
        {
            PhysicsBody* body = joint->getBodyA() == bodyA ? joint->getBodyB() : joint->getBodyA();
            
            if (body == bodyB)
            {
                contact.setNotificationEnable(false);
                return false;
            }
        }
    }
    
    // bitmask check
    if ((shapeA->getCategoryBitmask() & shapeB->getContactTestBitmask()) == 0
        || (shapeA->getContactTestBitmask() & shapeB->getCategoryBitmask()) == 0)
    {
        contact.setNotificationEnable(false);
    }
    
    if (shapeA->getGroup() != 0 && shapeA->getGroup() == shapeB->getGroup())
    {
        ret = shapeA->getGroup() > 0;
    }
    else
    {
        if ((shapeA->getCategoryBitmask() & shapeB->getCollisionBitmask()) == 0
            || (shapeB->getCategoryBitmask() & shapeA->getCollisionBitmask()) == 0)
        {
            ret = false;
        }
    }
    
    if (contact.isNotificationEnabled())
    {
        contact.setEventCode(PhysicsContact::EventCode::BEGIN);
        contact.setWorld(this);
        _eventDispatcher->dispatchEvent(&contact);
    }
    
    return ret ? contact.resetResult() : false;
}
开发者ID:114393824,项目名称:Cocos2dxShader,代码行数:59,代码来源:CCPhysicsWorld.cpp

示例2: collisionSeparateCallback

void PhysicsWorld::collisionSeparateCallback(PhysicsContact& contact)
{
    if (!contact.isNotificationEnabled())
    {
        return;
    }
    
    contact.setEventCode(PhysicsContact::EventCode::SEPARATE);
    contact.setWorld(this);
    _eventDispatcher->dispatchEvent(&contact);
}
开发者ID:114393824,项目名称:Cocos2dxShader,代码行数:11,代码来源:CCPhysicsWorld.cpp

示例3: collisionPostSolveCallback

void PhysicsWorld::collisionPostSolveCallback(PhysicsContact& contact)
{
    if (!contact.isNotificationEnabled())
    {
        return;
    }
    
    contact.setEventCode(PhysicsContact::EventCode::POSTSOLVE);
    contact.setWorld(this);
    _eventDispatcher->dispatchEvent(&contact);
}
开发者ID:114393824,项目名称:Cocos2dxShader,代码行数:11,代码来源:CCPhysicsWorld.cpp

示例4: collisionSeparateCallback

void PhysicsWorld::collisionSeparateCallback(PhysicsContact& contact)
{
    if (!contact.isNotificationEnabled())
    {
        return;
    }
    
    contact.setEventCode(PhysicsContact::EventCode::SEPERATE);
    contact.setWorld(this);
    EventCustom event(PHYSICSCONTACT_EVENT_NAME);
    event.setUserData(&contact);
    _scene->getEventDispatcher()->dispatchEvent(&event);
}
开发者ID:6520874,项目名称:pipiGame,代码行数:13,代码来源:CCPhysicsWorld.cpp

示例5: collisionPreSolveCallback

bool PhysicsWorld::collisionPreSolveCallback(PhysicsContact& contact)
{
    if (!contact.isNotificationEnabled())
    {
        return true;
    }
    
    contact.setEventCode(PhysicsContact::EventCode::PRESOLVE);
    contact.setWorld(this);
    _eventDispatcher->dispatchEvent(&contact);
    
    return contact.resetResult();
}
开发者ID:114393824,项目名称:Cocos2dxShader,代码行数:13,代码来源:CCPhysicsWorld.cpp

示例6: collisionPreSolveCallback

int PhysicsWorld::collisionPreSolveCallback(PhysicsContact& contact)
{
    if (!contact.isNotificationEnabled())
    {
        cpArbiterIgnore(static_cast<cpArbiter*>(contact._contactInfo));
        return true;
    }
    
    contact.setEventCode(PhysicsContact::EventCode::PRESOLVE);
    contact.setWorld(this);
    _scene->getEventDispatcher()->dispatchEvent(&contact);
    
    return contact.resetResult();
}
开发者ID:1251231390,项目名称:SushiCrush,代码行数:14,代码来源:CCPhysicsWorld.cpp

示例7: collisionPreSolveCallback

int PhysicsWorld::collisionPreSolveCallback(PhysicsContact& contact)
{
    if (!contact.isNotificationEnabled())
    {
        cpArbiterIgnore(static_cast<cpArbiter*>(contact.m_pContactInfo));
        return true;
    }
    
    contact.setEventCode(PhysicsContact::EventCode::PRESOLVE);
    contact.setWorld(this);
    EventCustom event(PHYSICSCONTACT_EVENT_NAME);
    event.setUserData(&contact);
    m_pScene->getEventDispatcher()->dispatchEvent(&event);
    
    return contact.resetResult();
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:16,代码来源:CCPhysicsWorld.cpp


注:本文中的PhysicsContact::setEventCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。