Esempio n. 1
0
        /**
         * Returns a boolean value that indicates whether a touch is inside the bounds
         * of the receiver. The given touch must be relative to the world.
         *
         * @param touch A CCTouch object that represents a touch.
         *
         * @return YES whether a touch is inside the receivers rect.
         */

        public virtual bool IsTouchInside(CCTouch touch)
        {
            CCPoint touchLocation = touch.LocationOnScreen;

            touchLocation = Parent.Layer.ScreenToWorldspace(touchLocation);
            CCRect bBox = BoundingBoxTransformedToWorld;

            return(bBox.ContainsPoint(touchLocation));
        }
        public override bool IsTouchInside(CCTouch touch)
        {
            CCPoint touchLocation = touch.Location;

            CCRect rect = BoundingBoxTransformedToWorld;

            rect.Size.Width += ThumbSprite.ContentSize.Width;
            rect.Origin.X   -= ThumbSprite.ContentSize.Width / 2;

            return(rect.ContainsPoint(touchLocation));
        }
Esempio n. 3
0
        protected virtual CCMenuItem ItemForTouch(CCTouch touch)
        {
            CCMenuItem touchedMenuItem = null;
            CCPoint    touchLocation   = touch.Location;

            if (menuItems != null && menuItems.Count > 0)
            {
                foreach (CCMenuItem menuItem in menuItems)
                {
                    if (menuItem != null && menuItem.Visible && menuItem.Enabled)
                    {
                        CCRect r = menuItem.BoundingBoxTransformedToWorld;

                        if (r.ContainsPoint(touchLocation))
                        {
                            touchedMenuItem = menuItem;
                            break;
                        }
                    }
                }
            }

            return(touchedMenuItem);
        }