コード例 #1
0
ファイル: CAViewController.cpp プロジェクト: wjm0729/CrossApp
void CANavigationController::ccTouchMoved(CATouch *pTouch, CAEvent *pEvent)
{
    CC_RETURN_IF(m_pViewControllers.size() <= 1);
    CC_RETURN_IF(m_bTouchMoved == false);
    float offDis = pTouch->getLocation().x - pTouch->getPreviousLocation().x;
    CAView* showContainer = m_pContainers.at(m_pContainers.size() - 2);
    if (!showContainer->getBounds().size.equals(this->getView()->getBounds().size))
    {
        showContainer->setFrame(this->getView()->getBounds());
    }
    showContainer->setVisible(true);
    showContainer->setTouchEnabled(false);
    
    CAView* backContainer = m_pContainers.back();
    
    DPoint point1 = backContainer->getFrameOrigin();
    point1.x += offDis;
    point1.x = MAX(point1.x, 0);
    point1.x = MIN(point1.x, this->getView()->getBounds().size.width);
    backContainer->setFrameOrigin(point1);
    backContainer->setTouchEnabled(false);
    
    DPoint point2 = showContainer->getCenterOrigin();
    point2.x = point1.x/2;
    showContainer->setCenterOrigin(point2);
    
    m_bPopViewController = ((offDis > 10) || point1.x > this->getView()->getBounds().size.width/4);
}