Пример #1
0
        /** override functions */
        // optional
        public override bool TouchBegan(CCTouch pTouch, CCEvent pEvent)
        {
            if (!Visible)
            {
                return(false);
            }

            CCPoint frameOriginal = Parent.ConvertToWorldSpace(Position);
            var     frame         = new CCRect(frameOriginal.X, frameOriginal.Y, m_tViewSize.Width, m_tViewSize.Height);

            //dispatcher does not know about clipping. reject touches outside visible bounds.
            if (m_pTouches.Count > 2 ||
                m_bTouchMoved ||
                !frame.ContainsPoint(m_pContainer.ConvertToWorldSpace(m_pContainer.ConvertTouchToNodeSpace(pTouch))))
            {
                return(false);
            }

            if (!m_pTouches.Contains(pTouch))
            {
                m_pTouches.Add(pTouch);
            }

            if (m_pTouches.Count == 1)
            {
                // scrolling
                m_tTouchPoint     = ConvertTouchToNodeSpace(pTouch);
                m_bTouchMoved     = false;
                m_bDragging       = true; //dragging started
                m_tScrollDistance = new CCPoint(0.0f, 0.0f);
                m_fTouchLength    = 0.0f;
            }
            else if (m_pTouches.Count == 2)
            {
                m_tTouchPoint = CCPoint.Midpoint(ConvertTouchToNodeSpace(m_pTouches[0]),
                                                 ConvertTouchToNodeSpace(m_pTouches[1]));
                m_fTouchLength = CCPoint.Distance(m_pContainer.ConvertTouchToNodeSpace(m_pTouches[0]),
                                                  m_pContainer.ConvertTouchToNodeSpace(m_pTouches[1]));
                m_bDragging = false;
            }
            return(true);
        }
Пример #2
0
        /** override functions */
        // optional
        public override bool TouchBegan(CCTouch pTouch)
        {
            if (!Visible)
            {
                return(false);
            }

            CCRect frame = GetViewRect();

            //dispatcher does not know about clipping. reject touches outside visible bounds.
            if (m_pTouches.Count > 2 ||
                m_bTouchMoved ||
                !frame.ContainsPoint(m_pContainer.ConvertToWorldSpace(m_pContainer.ConvertTouchToNodeSpace(pTouch))))
            {
                return(false);
            }

            if (!m_pTouches.Contains(pTouch))
            {
                m_pTouches.Add(pTouch);
            }

            if (m_pTouches.Count == 1)
            {
                // scrolling
                m_tTouchPoint     = ConvertTouchToNodeSpace(pTouch);
                m_bTouchMoved     = false;
                m_bDragging       = true; //dragging started
                m_tScrollDistance = CCPoint.Zero;
                m_fTouchLength    = 0.0f;
            }
            else if (m_pTouches.Count == 2)
            {
                m_tTouchPoint = CCPoint.Midpoint(ConvertTouchToNodeSpace(m_pTouches[0]),
                                                 ConvertTouchToNodeSpace(m_pTouches[1]));
                m_fTouchLength = CCPoint.Distance(m_pContainer.ConvertTouchToNodeSpace(m_pTouches[0]),
                                                  m_pContainer.ConvertTouchToNodeSpace(m_pTouches[1]));
                m_bDragging = false;
            }
            return(true);
        }