public override void ccTouchEnded(CCTouch touch, CCEvent ccevent) { if (this.m_pSelectedItem != null) { this.m_pSelectedItem.unselected(); this.m_pSelectedItem.activate(); } this.m_eState = tCCMenuState.kCCMenuStateWaiting; }
public override void ccTouchCancelled(CCTouch touch, CCEvent ccevent) { Debug.Assert(m_eState == tCCMenuState.kCCMenuStateTrackingTouch, "[Menu ccTouchCancelled] -- invalid state"); if (m_pSelectedItem != null) { m_pSelectedItem.unselected(); } m_eState = tCCMenuState.kCCMenuStateWaiting; }
public override void ccTouchMoved(CCTouch touch, CCEvent ccevent) { CCMenuItem cCMenuItem = this.itemForTouch(touch); if (cCMenuItem != this.m_pSelectedItem) { if (this.m_pSelectedItem != null) { this.m_pSelectedItem.unselected(); } this.m_pSelectedItem = cCMenuItem; if (this.m_pSelectedItem != null) { this.m_pSelectedItem.selected(); } } }
public override void ccTouchesMoved(List <cocos2d.CCTouch> touches, cocos2d.CCEvent event_) { CCSize s = CCDirector.sharedDirector().getWinSize(); var it = touches.FirstOrDefault(); CCTouch touch = (CCTouch)(it); CCPoint start = touch.locationInView(touch.view()); start = CCDirector.sharedDirector().convertToGL(start); CCPoint diff = new CCPoint(s.width / 2 - start.x, s.height / 2 - start.y); diff = CCPointExtension.ccpNormalize(diff); CCLayerGradient gradient = (CCLayerGradient)getChildByTag(1); gradient.Vector = diff; }
public override void ccTouchMoved(CCTouch touch, CCEvent ccevent) { Debug.Assert(m_eState == tCCMenuState.kCCMenuStateTrackingTouch, "[Menu ccTouchMoved] -- invalid state"); CCMenuItem currentItem = this.itemForTouch(touch); if (currentItem != m_pSelectedItem) { if (m_pSelectedItem != null) { m_pSelectedItem.unselected(); } m_pSelectedItem = currentItem; if (m_pSelectedItem != null) { m_pSelectedItem.selected(); } } }
public override bool ccTouchBegan(CCTouch touch, CCEvent ccevent) { if (this.m_eState != tCCMenuState.kCCMenuStateWaiting || !this.m_bIsVisible) { return(false); } for (CCNode i = this.m_pParent; i != null; i = i.parent) { if (!i.visible) { return(false); } } this.m_pSelectedItem = this.itemForTouch(touch); if (this.m_pSelectedItem == null) { return(false); } this.m_eState = tCCMenuState.kCCMenuStateTrackingTouch; this.m_pSelectedItem.selected(); return(true); }
public override void ccTouchesEnded(List <cocos2d.CCTouch> touches, cocos2d.CCEvent event_) { base.ccTouchesEnded(touches, event_); }
public virtual void ccTouchesCancelled(List <CCTouch> touches, CCEvent event_) { }
public virtual void ccTouchesEnded(List <CCTouch> touches, CCEvent event_) { }
public virtual void ccTouchesBegan(List <CCTouch> touches, CCEvent event_) { }
public virtual void ccTouchCancelled(CCTouch touch, CCEvent event_) { }
public virtual void ccTouchEnded(CCTouch touch, CCEvent event_) { }
public virtual bool ccTouchBegan(CCTouch touch, CCEvent event_) { // Debug.Assert(false, "Layer#ccTouchBegan override me"); return(true); }
public void touches(List <CCTouch> pTouches, CCEvent pEvent, int uIndex) { List <CCTouch> pMutableTouches; m_bLocked = true; // optimization to prevent a mutable copy when it is not necessary int uTargetedHandlersCount = m_pTargetedHandlers.Count; int uStandardHandlersCount = m_pStandardHandlers.Count; bool bNeedsMutableSet = (uTargetedHandlersCount > 0 && uStandardHandlersCount > 0); if (bNeedsMutableSet) { CCTouch[] tempArray = pTouches.ToArray(); pMutableTouches = tempArray.ToList(); } else { pMutableTouches = pTouches; } CCTouchType sHelper = (CCTouchType)uIndex; // process the target handlers 1st if (uTargetedHandlersCount > 0) { #region CCTargetedTouchHandler foreach (CCTouch pTouch in pTouches) { foreach (CCTargetedTouchHandler pHandler in m_pTargetedHandlers) { ICCTargetedTouchDelegate pDelegate = (ICCTargetedTouchDelegate)(pHandler.Delegate); bool bClaimed = false; if (sHelper == CCTouchType.CCTOUCHBEGAN) { bClaimed = pDelegate.ccTouchBegan(pTouch, pEvent); if (bClaimed) { pHandler.ClaimedTouches.Add(pTouch); } } else { if (pHandler.ClaimedTouches.Contains(pTouch)) { // moved ended cancelled bClaimed = true; switch (sHelper) { case CCTouchType.CCTOUCHMOVED: pDelegate.ccTouchMoved(pTouch, pEvent); break; case CCTouchType.CCTOUCHENDED: pDelegate.ccTouchEnded(pTouch, pEvent); pHandler.ClaimedTouches.Remove(pTouch); break; case CCTouchType.CCTOUCHCANCELLED: pDelegate.ccTouchCancelled(pTouch, pEvent); pHandler.ClaimedTouches.Remove(pTouch); break; } } } if (bClaimed && pHandler.IsSwallowsTouches) { if (bNeedsMutableSet) { pMutableTouches.Remove(pTouch); } break; } } } #endregion } // process standard handlers 2nd if (uStandardHandlersCount > 0 && pMutableTouches.Count > 0) { #region CCStandardTouchHandler foreach (CCStandardTouchHandler pHandler in m_pStandardHandlers) { ICCStandardTouchDelegate pDelegate = (ICCStandardTouchDelegate)pHandler.Delegate; switch (sHelper) { case CCTouchType.CCTOUCHBEGAN: pDelegate.ccTouchesBegan(pMutableTouches, pEvent); break; case CCTouchType.CCTOUCHMOVED: pDelegate.ccTouchesMoved(pMutableTouches, pEvent); break; case CCTouchType.CCTOUCHENDED: pDelegate.ccTouchesEnded(pMutableTouches, pEvent); break; case CCTouchType.CCTOUCHCANCELLED: pDelegate.ccTouchesCancelled(pMutableTouches, pEvent); break; } } #endregion } if (bNeedsMutableSet) { pMutableTouches = null; } // // Optimization. To prevent a [handlers copy] which is expensive // the add/removes/quit is done after the iterations // m_bLocked = false; if (m_bToRemove) { m_bToRemove = false; for (int i = 0; i < m_pHandlersToRemove.Count; ++i) { forceRemoveDelegate((ICCTouchDelegate)m_pHandlersToRemove[i]); } m_pHandlersToRemove.Clear(); } if (m_bToAdd) { m_bToAdd = false; foreach (CCTouchHandler pHandler in m_pHandlersToAdd) { if (pHandler is CCTargetedTouchHandler && pHandler.Delegate is ICCTargetedTouchDelegate) { forceAddHandler(pHandler, m_pTargetedHandlers); } else if (pHandler is CCStandardTouchHandler && pHandler.Delegate is ICCStandardTouchDelegate) { forceAddHandler(pHandler, m_pStandardHandlers); } else { CCLog.Log("ERROR: inconsistent touch handler and delegate found in m_pHandlersToAdd of CCTouchDispatcher"); } } m_pHandlersToAdd.Clear(); } if (m_bToQuit) { m_bToQuit = false; forceRemoveAllDelegates(); } }
public void touches(List <CCTouch> pTouches, CCEvent pEvent, int uIndex) { List <CCTouch> cCTouches; this.m_bLocked = true; int count = this.m_pTargetedHandlers.Count; int num = this.m_pStandardHandlers.Count; bool flag = (count <= 0 ? false : num > 0); cCTouches = (!flag ? pTouches : pTouches.ToArray().ToList <CCTouch>()); CCTouchType cCTouchType = (CCTouchType)uIndex; if (count > 0) { foreach (CCTouch pTouch in pTouches) { foreach (CCTargetedTouchHandler mPTargetedHandler in this.m_pTargetedHandlers) { ICCTargetedTouchDelegate @delegate = (ICCTargetedTouchDelegate)mPTargetedHandler.Delegate; bool flag1 = false; if (cCTouchType == CCTouchType.CCTOUCHBEGAN) { flag1 = @delegate.ccTouchBegan(pTouch, pEvent); if (flag1) { mPTargetedHandler.ClaimedTouches.Add(pTouch); } } else if (mPTargetedHandler.ClaimedTouches.Contains(pTouch)) { flag1 = true; switch (cCTouchType) { case CCTouchType.CCTOUCHMOVED: { @delegate.ccTouchMoved(pTouch, pEvent); break; } case CCTouchType.CCTOUCHENDED: { @delegate.ccTouchEnded(pTouch, pEvent); mPTargetedHandler.ClaimedTouches.Remove(pTouch); break; } case CCTouchType.CCTOUCHCANCELLED: { @delegate.ccTouchCancelled(pTouch, pEvent); mPTargetedHandler.ClaimedTouches.Remove(pTouch); break; } } } if (!flag1 || !mPTargetedHandler.IsSwallowsTouches) { continue; } if (!flag) { break; } cCTouches.Remove(pTouch); break; } } } if (num > 0 && cCTouches.Count > 0) { foreach (CCStandardTouchHandler mPStandardHandler in this.m_pStandardHandlers) { ICCStandardTouchDelegate cCStandardTouchDelegate = (ICCStandardTouchDelegate)mPStandardHandler.Delegate; switch (cCTouchType) { case CCTouchType.CCTOUCHBEGAN: { cCStandardTouchDelegate.ccTouchesBegan(cCTouches, pEvent); continue; } case CCTouchType.CCTOUCHMOVED: { cCStandardTouchDelegate.ccTouchesMoved(cCTouches, pEvent); continue; } case CCTouchType.CCTOUCHENDED: { cCStandardTouchDelegate.ccTouchesEnded(cCTouches, pEvent); continue; } case CCTouchType.CCTOUCHCANCELLED: { cCStandardTouchDelegate.ccTouchesCancelled(cCTouches, pEvent); continue; } default: { continue; } } } } if (flag) { cCTouches = null; } this.m_bLocked = false; if (this.m_bToRemove) { this.m_bToRemove = false; for (int i = 0; i < this.m_pHandlersToRemove.Count; i++) { this.forceRemoveDelegate((ICCTouchDelegate)this.m_pHandlersToRemove[i]); } this.m_pHandlersToRemove.Clear(); } if (this.m_bToAdd) { this.m_bToAdd = false; foreach (CCTouchHandler mPHandlersToAdd in this.m_pHandlersToAdd) { if (mPHandlersToAdd is CCTargetedTouchHandler && mPHandlersToAdd.Delegate is ICCTargetedTouchDelegate) { this.forceAddHandler(mPHandlersToAdd, this.m_pTargetedHandlers); } else if (!(mPHandlersToAdd is CCStandardTouchHandler) || !(mPHandlersToAdd.Delegate is ICCStandardTouchDelegate)) { CCLog.Log("ERROR: inconsistent touch handler and delegate found in m_pHandlersToAdd of CCTouchDispatcher"); } else { this.forceAddHandler(mPHandlersToAdd, this.m_pStandardHandlers); } } this.m_pHandlersToAdd.Clear(); } if (this.m_bToQuit) { this.m_bToQuit = false; this.forceRemoveAllDelegates(); } }
public virtual bool ccTouchBegan(CCTouch touch, CCEvent event_) { return(true); }