Beispiel #1
0
        protected CCMenuItem itemForTouch(CCTouch touch)
        {
            CCMenuItem cCMenuItem;
            CCPoint    gL = touch.locationInView(touch.view());

            gL = CCDirector.sharedDirector().convertToGL(gL);
            if (this.m_pChildren != null && this.m_pChildren.Count > 0)
            {
                List <CCNode> .Enumerator enumerator = this.m_pChildren.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        CCNode current = enumerator.Current;
                        if (current == null || !current.visible || !((CCMenuItem)current).Enabled)
                        {
                            continue;
                        }
                        CCPoint nodeSpace = current.convertToNodeSpace(gL);
                        CCRect  zero      = ((CCMenuItem)current).rect();
                        zero.origin = CCPoint.Zero;
                        if (!CCRect.CCRectContainsPoint(zero, nodeSpace))
                        {
                            continue;
                        }
                        cCMenuItem = (CCMenuItem)current;
                        return(cCMenuItem);
                    }
                    return(null);
                }
                finally
                {
                    ((IDisposable)enumerator).Dispose();
                }
                return(cCMenuItem);
            }
            return(null);
        }