Esempio n. 1
0
        public override DisplayObject HitTest(Point localPoint)
        {
            if (!Visible || !Touchable || !HitTestMask(localPoint))
            {
                return(null);
            }

            for (int i = _children.Count - 1; i >= 0; --i)
            {
                // front to back!
                DisplayObject child = _children[i];
                if (child.IsMask)
                {
                    continue;
                }


                Matrix2D transformationMatrix = Matrix2D.Create();
                transformationMatrix.CopyFromMatrix(child.TransformationMatrix);
                transformationMatrix.Invert();

                Point         transformedPoint = transformationMatrix.TransformPoint(localPoint);
                DisplayObject target           = child.HitTest(transformedPoint);
                if (target != null)
                {
                    return(TouchGroup ? this : target);
                }
            }
            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Checks if a certain point is inside the display object's mask. If there is no mask,
        /// this method always returns <code>true</code> (because having no mask is equivalent
        /// to having one that's infinitely big).
        /// </summary>
        public bool HitTestMask(Point localPoint)
        {
            if (_mask == null)
            {
                return(true);
            }
            if (_mask.Stage != null)
            {
                _sHelperMatrixAlt = GetTransformationMatrix(_mask);
            }
            else
            {
                _sHelperMatrixAlt.CopyFromMatrix(_mask.TransformationMatrix);
                _sHelperMatrixAlt.Invert();
            }

            var helperPoint = _sHelperMatrixAlt.TransformPoint(localPoint);

            return(_mask.HitTest(helperPoint) != null);
        }