Esempio n. 1
0
        public EmbarkLayer() : base(CCColor4B.Gray)
        {
            // Nodes
            label    = new CCLabel("Option 1", "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont);
            drawNode = new CCDrawNode();
            AddChild(label);
            AddChild(drawNode);

            mouseLabel = new CCLabel($"X: 0 Y: 0", "fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont);
            AddChild(mouseLabel);

            yesNo = new YesNoControl();
            drawNode.AddChild(yesNo);

            startButton = new UIButton(new CCSprite("UI/start"))
            {
                SpriteAnchorPoint = CCPoint.AnchorMiddle, Position = new CCPoint(VisibleBoundsWorldspace.MidX, 200)
            };
            startButton.OnClick = Start;
            AddChild(startButton);

            //Events
            var moveListener = new CCEventListenerMouse();

            moveListener.OnMouseMove = (ev) =>
            {
                mouseLabel.Text     = $"X: {ev.CursorX} Y: {VisibleBoundsWorldspace.MaxY - ev.CursorY}";
                mouseLabel.Position = new CCPoint(ev.CursorX, VisibleBoundsWorldspace.MaxY - ev.CursorY);
            };
            AddEventListener(moveListener);
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="window"></param>
 public WrappedScene() : base(AppDelegate.SharedWindow)
 {
     AddEventListener(MouseListener = new CCEventListenerMouse()
     {
         OnMouseDown = OnMouseDown,
         OnMouseUp   = OnMouseUp,
     });
     AddEventListener(KeyboardListener = new CCEventListenerKeyboard()
     {
         OnKeyPressed  = OnKeyPressed,
         OnKeyReleased = OnKeyReleased,
     });
 }
Esempio n. 4
0
        public ClickableNode()
        {
            var clickListener = new CCEventListenerMouse();

            clickListener.OnMouseUp = (ev) =>
            {
                if (this.IsClickOnMe(ev) && OnClick != null)
                {
                    OnClick.Invoke(ev);
                }
            };
            AddEventListener(clickListener);
        }
Esempio n. 5
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            // Use the bounds to layout the positioning of our drawable assets
            var bounds = VisibleBoundsWorldspace;

            // position the label on the center of the screen
            label.Position = bounds.Center;

            var listener = new CCEventListenerMouse();

            listener.OnMouseUp = OnMouseUp;
            label.AddEventListener(listener);
            //AddEventListener(listener, label);
        }
Esempio n. 6
0
        public UIButton(CCSprite sprite)
        {
            _sprite            = sprite;
            sprite.AnchorPoint = CCPoint.AnchorUpperLeft;
            AddChild(sprite);

            var clickListener = new CCEventListenerMouse();

            clickListener.OnMouseUp = (ev) =>
            {
                if (sprite.IsClickOnMe(ev) && OnClick != null)
                {
                    OnClick.Invoke(ev);
                }
            };
            AddEventListener(clickListener);
        }
Esempio n. 7
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            // Use the bounds to layout the positioning of our drawable assets
            var windowSize = VisibleBoundsWorldspace.Size;

            // position the label on the center of the screen
            eventText.Position      = new CCPoint(windowSize.Width / 2, windowSize.Height - 85);
            reactionHeader.Position = new CCPoint(windowSize.Width / 2, 300f);
            reactionMenu.Position   = new CCPoint(150f, 200f);

            // Register for events
            var mouseListener = new CCEventListenerMouse();

            mouseListener.OnMouseDown = OnMouseDown;
            AddEventListener(mouseListener, this);
        }
Esempio n. 8
0
        public PlayLayer() : base(CCColor4B.Black)
        {
            GUILayer         = new GUILayer(this);
            TouchCountSource = GUILayer;
            BGNode           = new CCNode();
            AddChild(BGNode);
            BGNode.VertexZ = Constants.VERTEX_Z_GROUND;
            BGNode.AddChild(DrawNode);
            BGNode.AddChild(DrawNodeBG);
            DrawNodeBG.BlendFunc = CCBlendFunc.NonPremultiplied;  // necessary for alpha to work
            BGNode.ZOrder        = (int)Constants.VERTEX_Z_GROUND;
            BGNode.Rotation      = 10f;

            AddChild(DrawNodeExplosions, -2000);
            DrawNodeExplosions.VertexZ   = Constants.VERTEX_Z_GROUND + 1;
            DrawNodeExplosions.BlendFunc = CCBlendFunc.NonPremultiplied;

            HighDrawNode           = new CCDrawNode();
            HighDrawNode.BlendFunc = CCBlendFunc.NonPremultiplied;
            AddChild(HighDrawNode, zOrder: 1000);
            LowDrawNode           = new CCDrawNode();
            LowDrawNode.BlendFunc = CCBlendFunc.NonPremultiplied;
            AddChild(LowDrawNode, zOrder: -1000);

            MaxCameraWidth  = Constants.COCOS_WORLD_WIDTH * 10;
            MaxCameraHeight = Constants.COCOS_WORLD_HEIGHT * 10;

            // add a touch listener
            var touchListener = new CCEventListenerTouchAllAtOnce();

            touchListener.OnTouchesBegan     = OnTouchesBegan;
            touchListener.OnTouchesMoved     = OnTouchesMovedMoveAndZoom;
            touchListener.OnTouchesEnded     = OnTouchesEnded;
            touchListener.OnTouchesCancelled = OnTouchesEnded;
            AddEventListener(touchListener, int.MaxValue);

            // add a mouse listener
            var mouseListener = new CCEventListenerMouse();

            mouseListener.OnMouseScroll = OnMouseScrollZoom;
            AddEventListener(mouseListener, int.MaxValue);
        }
Esempio n. 9
0
        public override void OnEnter()
        {
            CCRect visibleBounds = VisibleBoundsWorldspace;

            base.OnEnter();

            int line = (int)(visibleBounds.Size.Height / 2);

            mousePosition             = new CCLabelTtf("Mouse Position: ", "arial", 20);
            mousePosition.Position    = new CCPoint(130, line + 60);
            mousePosition.AnchorPoint = CCPoint.AnchorMiddleLeft;
            AddChild(mousePosition);

            mouseButtonDown             = new CCLabelTtf("Mouse Button Down: ", "arial", 20);
            mouseButtonDown.Position    = new CCPoint(130, line + 20);
            mouseButtonDown.AnchorPoint = CCPoint.AnchorMiddleLeft;
            AddChild(mouseButtonDown);

            mouseButtonUp             = new CCLabelTtf("Mouse Button Up: ", "arial", 20);
            mouseButtonUp.Position    = new CCPoint(130, line - 20);
            mouseButtonUp.AnchorPoint = CCPoint.AnchorMiddleLeft;
            AddChild(mouseButtonUp);

            scrollWheel             = new CCLabelTtf("Scroll Wheel Delta: ", "arial", 20);
            scrollWheel.Position    = new CCPoint(130, line - 60);
            scrollWheel.AnchorPoint = CCPoint.AnchorMiddleLeft;
            AddChild(scrollWheel);


            var mouseListener = new CCEventListenerMouse();

            mouseListener.OnMouseScroll = OnMouseScroll;
            mouseListener.OnMouseDown   = OnMouseDown;
            mouseListener.OnMouseUp     = OnMouseUp;
            mouseListener.OnMouseMove   = OnMouseMove;
            AddEventListener(mouseListener);
        }
Esempio n. 10
0
 public CrapMenuButton(CCColor3B colour, string label)
 {
     this.colour        = colour;
     this.label         = label;
     ClickEventListener = new CCEventListenerMouse();
 }