コード例 #1
0
ファイル: Menu.cs プロジェクト: hcxyzlm/CocosNet-1
        public Menu(params MenuItem[] items)
        {
            IsTouchEnabled = true;
            SizeF s = Director.Instance.WinSize;
            IsRelativeAnchorPoint = false;

            AnchorPoint = new PointF(0.5f, 0.5f);
            ContentSize = s;

            RectangleF r = UIApplication.SharedApplication.StatusBarFrame;
            DeviceOrientation orientation = Director.Instance.DeviceOrientation;

            if (orientation == DeviceOrientation.LandscapeLeft || orientation == DeviceOrientation.LandscapeRight) {
                s.Height -= r.Width;
            } else {
                s.Height -= r.Height;
            }

            SetPosition(s.Width / 2f, s.Height / 2f);

            int z = 0;

            IsRunning = true;

            foreach (MenuItem item in items) {
                AddChild(item, z);
                ++z;
            }

            _state = MenuState.Waiting;
            _selectedItem = null;
        }
コード例 #2
0
ファイル: Menu.cs プロジェクト: hcxyzlm/CocosNet-1
        public override void TouchMoved(UITouch touch, UIEvent evnt)
        {
            Debug.Assert(_state == MenuState.TrackingTouch, "Menu.TouchEnded, invalid state");

            MenuItem currentItem = ItemForTouch(touch);

            if (currentItem != _selectedItem) {
                if (_selectedItem != null) {
                    _selectedItem.OnUnselected();
                }

                _selectedItem = currentItem;

                if (_selectedItem != null) {
                    _selectedItem.OnSelected();
                }
            }
        }
コード例 #3
0
ファイル: Menu.cs プロジェクト: hcxyzlm/CocosNet-1
        public override bool TouchBegan(UITouch touch, UIEvent evnt)
        {
            if (_state != MenuState.Waiting) {
                return false;
            }

            _selectedItem = ItemForTouch(touch);

            if (_selectedItem != null) {
                _selectedItem.OnSelected();
                _state = MenuState.TrackingTouch;

                return true;
            }

            return false;
        }