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); }
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); }
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; }
public override void ccTouchCancelled(UITouch touch) { NSUtils.Assert(_state == kCCMenuState.TrackingTouch, "[Menu ccTouchCancelled] -- invalid state"); _selectedItem.unselected(); _state = kCCMenuState.Waiting; }
public override void onExit() { if (_state == kCCMenuState.TrackingTouch) { _selectedItem.unselected(); _state = kCCMenuState.Waiting; _selectedItem = null; } base.onExit(); }
private void touchCancelled() { // NSUtils.Assert(_state == kCCMenuState.TrackingTouch, "[Menu ccTouchCancelled] -- invalid state"); if (_state != kCCMenuState.TrackingTouch) { return; } _selectedItem.unselected(); _state = kCCMenuState.Waiting; }
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; }
public override void onExit () { if(_state == kCCMenuState.TrackingTouch) { _selectedItem.unselected(); _state = kCCMenuState.Waiting; _selectedItem = null; } base.onExit (); }
public override void ccTouchCancelled (UITouch touch) { NSUtils.Assert(_state == kCCMenuState.TrackingTouch, "[Menu ccTouchCancelled] -- invalid state"); _selectedItem.unselected(); _state = kCCMenuState.Waiting; }
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; }