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


C++ CVector2::Distance方法代码示例

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


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

示例1: HandleInput

bool CGesturer::HandleInput(CInputEvent* _event)
{
    bool recognizedDrag = false;

#ifndef WALO_PLATFORM_WIN
    if(_event->InputType == CInputEvent::EIT_TOUCH)
    {
        CTouchEvent* tevent = (CTouchEvent*)_event;
        if(tevent->TouchCount > 1)
        {
            m_bDragging = false;
            CVector2 ptFirstFinger = CVector2(tevent->Touches[0].X, tevent->Touches[0].Y);
            CVector2 ptSecondFinger = CVector2(tevent->Touches[1].X, tevent->Touches[1].Y);
            f32 zoom = ptSecondFinger.Distance(ptFirstFinger);
            f32 roto = CMath::Atan2(ptSecondFinger.Y - ptFirstFinger.Y, ptSecondFinger.X - ptFirstFinger.X);

            if(tevent->Touches[0].TouchType == CTouchEvent::ETE_BEGIN || tevent->Touches[1].TouchType == CTouchEvent::ETE_BEGIN)
            {
                _BeginRotoZoom(roto, zoom);
                return true;
            }
            else 
            if(tevent->Touches[0].TouchType == CTouchEvent::ETE_MOVE || tevent->Touches[1].TouchType == CTouchEvent::ETE_MOVE)
            {
                _DoRotoZoom(roto, zoom);
                return true;
            }
            else
            {
                if(m_bZoomRot)
                {
                    m_bZoomRot = false;
                    return false;
                }
            }
        }
        else
        {
            m_bZoomRot = false;
            
            if(tevent->Touches[0].TouchType == CTouchEvent::ETE_BEGIN)
            {
                m_DragStart.X = tevent->Touches[0].X;
                m_DragStart.Y = tevent->Touches[0].Y;
                m_bDragging = false;
            }
            else
            if(tevent->Touches[0].TouchType == CTouchEvent::ETE_MOVE)
            {
                if(!m_bDragging)
                {
                    recognizedDrag = _RecognizeDrag(tevent->Touches[0].X, tevent->Touches[0].Y);

                    if(recognizedDrag)
                        _BeginDrag(tevent->Touches[0].X, tevent->Touches[0].Y);
                }
                else
                    _DoDrag(tevent->Touches[0].X, tevent->Touches[0].Y);
            }
            else
            {
                if(!m_bDragging)
                {
                    _HandleTap(tevent->Touches[0].X, tevent->Touches[0].Y);
                    recognizedDrag = true;
                }

                m_bDragging = false;
            }
            
            return recognizedDrag;
        }
    }
    else
#endif
    if(_event->InputType == CInputEvent::EIT_MOUSE)
    {
        CMouseEvent* mevent = (CMouseEvent*)_event;

        if((mevent->Buttons & CMouseEvent::EMBM_LEFT) && !m_MLBPressed)
        {
            m_DragStart.X = mevent->X;
            m_DragStart.Y = mevent->Y;

            m_bDragging = false;
            m_MLBPressed = true;
        }
        else
        if((mevent->Buttons & CMouseEvent::EMBM_LEFT) && m_MLBPressed)
        {
            if(!m_bDragging)
            {
                recognizedDrag = _RecognizeDrag(mevent->X, mevent->Y);

                if(recognizedDrag)
                    _BeginDrag(mevent->X, mevent->Y);
            }
            else
                _DoDrag(mevent->X, mevent->Y);
        }
//.........这里部分代码省略.........
开发者ID:dexmas,项目名称:WaloEngine,代码行数:101,代码来源:Gesturer.cpp


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