Пример #1
0
        public override bool ccTouchBegan(UITouch touch)
        {
            if (_state != kCCMenuState.Waiting || !_visible || !_enabled)
            {
                return(false);
            }

            for (CCNode c = this.parent; c != null; c = c.parent)
            {
                if (c.visible == false)
                {
                    return(false);
                }
            }

            _selectedItem = itemForTouch(touch);

            if (_selectedItem != null)
            {
                _selectedItem.selected();
                _state = kCCMenuState.TrackingTouch;
                return(true);
            }
            return(false);
        }
Пример #2
0
        private bool touchBegan(CCMenuItem touchedItem)
        {
            if (_state != kCCMenuState.Waiting || !_visible || !_enabled)
            {
                return(false);
            }

            for (CCNode c = this.parent; c != null; c = c.parent)
            {
                if (c.visible == false)
                {
                    return(false);
                }
            }

            _selectedItem = touchedItem;

            if (_selectedItem != null)
            {
                _selectedItem.selected();
                _state = kCCMenuState.TrackingTouch;
                return(true);
            }
            return(false);
        }
Пример #3
0
		protected virtual void initWithArray(List<CCMenuItem> arrayOfItems){
			this.touchPriority = kCCMenuHandlerPriority;
			this.touchMode = kCCTouchesMode.OneByOne;
			this.isTouchEnabled = true;
			_enabled = true;
			
			// by default, menu in the center of the screen
			Vector2 s = CCDirector.sharedDirector.winSize;
			
			this.ignoreAnchorPointForPosition = true;
			_anchorPoint = new Vector2(0.5f, 0.5f);
			this.contentSize = s;


			this.position = s / 2;
			
			int z=0;

			if(arrayOfItems!=null){
				var enumerator = arrayOfItems.GetEnumerator();
				while (enumerator.MoveNext()) {
					CCMenuItem item = enumerator.Current;
					addChild(item, z);
					z++;
				}
			}
			_selectedItem = null;
			_state = kCCMenuState.Waiting;
			
			// enable cascade color and opacity on menus
			this.cascadeColorEnabled = true;
			this.cascadeOpacityEnabled = true;
		}
Пример #4
0
        public override void ccTouchCancelled(UITouch touch)
        {
            NSUtils.Assert(_state == kCCMenuState.TrackingTouch, "[Menu ccTouchCancelled] -- invalid state");

            _selectedItem.unselected();

            _state = kCCMenuState.Waiting;
        }
Пример #5
0
 public override void onExit()
 {
     if (_state == kCCMenuState.TrackingTouch)
     {
         _selectedItem.unselected();
         _state        = kCCMenuState.Waiting;
         _selectedItem = null;
     }
     base.onExit();
 }
Пример #6
0
        private void touchCancelled()
        {
//            NSUtils.Assert(_state == kCCMenuState.TrackingTouch, "[Menu ccTouchCancelled] -- invalid state");
            if (_state != kCCMenuState.TrackingTouch)
            {
                return;
            }
            _selectedItem.unselected();
            _state = kCCMenuState.Waiting;
        }
Пример #7
0
        protected virtual void initWithArray(List <CCMenuItem> arrayOfItems)
        {
            this.nameInHierarchy = "menu";
            this.touchPriority   = kCCMenuHandlerPriority;
            this.touchMode       = kCCTouchesMode.OneByOne;
            this.isTouchEnabled  = true;
            this.isMouseEnabled  = true;
            this.mousePriority   = this.touchPriority;
            _enabled             = true;

            // by default, menu in the center of the screen
            Vector2 s = CCDirector.sharedDirector.winSize;

            this.ignoreAnchorPointForPosition = true;
            _anchorPoint     = new Vector2(0.5f, 0.5f);
            this.contentSize = s;


            this.position = s / 2;

            int z = 0;

            if (arrayOfItems != null)
            {
                var enumerator = arrayOfItems.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    CCMenuItem item = enumerator.Current;
                    addChild(item, z);
                    z++;
                }
            }
            _selectedItem = null;
            _state        = kCCMenuState.Waiting;

            // enable cascade color and opacity on menus
            this.cascadeColorEnabled   = true;
            this.cascadeOpacityEnabled = true;
        }
Пример #8
0
		public override void onExit ()
		{
			if(_state == kCCMenuState.TrackingTouch)
			{
				_selectedItem.unselected();
				_state = kCCMenuState.Waiting;
				_selectedItem = null;
			}
			base.onExit ();
		}
Пример #9
0
		public override void ccTouchCancelled (UITouch touch)
		{
			NSUtils.Assert(_state == kCCMenuState.TrackingTouch, "[Menu ccTouchCancelled] -- invalid state");
			
			_selectedItem.unselected();
			
			_state = kCCMenuState.Waiting;
		}
Пример #10
0
		public override bool ccTouchBegan (UITouch touch)
		{
			if( _state != kCCMenuState.Waiting || !_visible || ! _enabled)
				return false;
			
			for( CCNode c = this.parent; c != null; c = c.parent )
				if( c.visible == false )
					return false;
			
			_selectedItem = itemForTouch(touch);
			
			if( _selectedItem!=null ) {
				_selectedItem.selected();
				_state = kCCMenuState.TrackingTouch;
				return true;
			}
			return false;
		}