FairyGUI.DisplayObject.HitTest C# (CSharp) Method

HitTest() protected method

protected HitTest ( ) : DisplayObject
return DisplayObject
        protected virtual DisplayObject HitTest()
        {
            Rect rect = GetBounds(this);
            if (rect.width == 0 || rect.height == 0)
                return null;

            Vector2 localPoint = WorldToLocal(HitTestContext.worldPoint, HitTestContext.direction);
            if (rect.Contains(localPoint))
                return this;
            else
                return null;
        }

Usage Example

示例#1
0
        public override DisplayObject HitTest(Vector2 localPoint, bool forTouch)
        {
            if (_skipRendering)
            {
                return(null);
            }

            if (forTouch && (!visible || !touchable || optimizeNotTouchable))
            {
                return(null);
            }

            if (_clipRect != null && !((Rect)_clipRect).Contains(localPoint))
            {
                return(null);
            }
            else
            {
                int           count  = _children.Count;
                DisplayObject target = null;
                for (int i = count - 1; i >= 0; --i)                 // front to back!
                {
                    DisplayObject child = _children[i];

                    Vector2 v = TransformPoint(localPoint, child);
                    target = child.HitTest(v, forTouch);

                    if (target != null)
                    {
                        break;
                    }
                }

                if (target == null && _hitArea != null)
                {
                    if (((Rect)_hitArea).Contains(localPoint))
                    {
                        target = this;
                    }
                }

                return(target);
            }
        }
All Usage Examples Of FairyGUI.DisplayObject::HitTest