コード例 #1
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCRect visibleBounds = Layer.VisibleBoundsWorldspace;

            // Laying out content based on window size
            closeMenu.Position     = CCPoint.Zero;
            closeMenuItem.Position = new CCPoint(visibleBounds.Size.Width - 40, visibleBounds.Size.Height - 40);

#if !PSM && !WINDOWS_PHONE
            versionLabel.AnchorPoint = CCPoint.AnchorUpperLeft;
            versionLabel.Position    = new CCPoint(10.0f, visibleBounds.Size.Height);
#endif
            testListMenu.ContentSize = new CCSize(visibleBounds.Size.Width, (testCases.Count + 1) * LINE_SPACE);

            int i = 0;
            foreach (CCMenuItem testItem in testListMenuItems)
            {
                testItem.Position = new CCPoint(visibleBounds.Size.Center.X, (visibleBounds.Top().Y - (i + 1) * LINE_SPACE));
                i++;
            }

            #if XBOX || OUYA
            // Center the menu on the first item so that it is
            // in the center of the screen
            homePosition = new CCPoint(0f, visibleBounds.Size.Height / 2f + LINE_SPACE / 2f);
            lastPosition = new CCPoint(0f, homePosition.Y - (testListMenuItems.Count - 1) * LINE_SPACE);
            #else
            homePosition = curPos;
            #endif

            testListMenu.Position = homePosition;

            // Add listeners
            #if !XBOX && !OUYA
            var touchListener = new CCEventListenerTouchOneByOne();
            touchListener.IsSwallowTouches = true;
            touchListener.OnTouchBegan     = OnTouchBegan;
            touchListener.OnTouchMoved     = OnTouchMoved;

            AddEventListener(touchListener);

            var mouseListener = new CCEventListenerMouse();
            mouseListener.OnMouseScroll = OnMouseScroll;
            AddEventListener(mouseListener);
            #endif

            #if WINDOWS || WINDOWSGL || MACOS
            EnableGamePad();
            #endif

            // set the first one to have the selection highlight
            currentItemIndex = 0;
            //SelectMenuItem();
        }