示例#1
0
bool SoaringLayer::onContactBegin(PhysicsContact& contact)
{
    Node* nodes[2];
    nodes[0] = contact.getShapeA()->getBody()->getNode();
    nodes[1] = contact.getShapeB()->getBody()->getNode();
    
    if (nodes[0] && nodes[1])
    {
        for (int i = 0; i < 2; i++)
        {
            int j = (i + 1) % 2;
            
            if (nodes[i]->getTag() == FLYPLANT_TAG)
            {
                FlyPlant *flyPlant = dynamic_cast<FlyPlant*>(nodes[i]);
                if (flyPlant)
                {
                    flyPlant->onContactBegin(nodes[j]);
                }
            }
            if (nodes[i]->getTag() == OBSTACLE_TAG)
            {
                Obstacle *obstacle = dynamic_cast<Obstacle*>(nodes[i]);
                if (obstacle)
                {
                    obstacle->onContactBegin(nodes[j]);
                }
            }
        }
    }
    
    return false;
}