/// <summary> /// For phone event handle functions /// </summary> public override bool ccTouchBegan(CCTouch touch, CCEvent ccevent) { if (m_eState != tCCMenuState.kCCMenuStateWaiting || !m_bIsVisible) { return(false); } for (CCNode c = this.m_pParent; c != null; c = c.parent) { if (c.visible == false) { return(false); } } m_pSelectedItem = this.itemForTouch(touch); if (m_pSelectedItem != null) { m_eState = tCCMenuState.kCCMenuStateTrackingTouch; m_pSelectedItem.selected(); return(true); } return(false); }
public override void ccTouchCancelled(CCTouch touch, CCEvent ccevent) { if (this.m_pSelectedItem != null) { this.m_pSelectedItem.unselected(); } this.m_eState = tCCMenuState.kCCMenuStateWaiting; }
public override void onExit() { if (this.m_eState == tCCMenuState.kCCMenuStateTrackingTouch) { this.m_pSelectedItem.unselected(); this.m_eState = tCCMenuState.kCCMenuStateWaiting; this.m_pSelectedItem = null; } base.onExit(); }
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; }
/// <summary> /// initializes a CCMenu with it's items /// </summary> bool initWithItems(params CCMenuItem[] item) { if (base.init()) { this.m_bIsTouchEnabled = true; // menu in the center of the screen CCSize s = CCDirector.sharedDirector().getWinSize(); this.m_bIsRelativeAnchorPoint = false; anchorPoint = new CCPoint(0.5f, 0.5f); this.contentSize = s; // XXX: in v0.7, winSize should return the visible size // XXX: so the bar calculation should be done there CCRect r; CCApplication.sharedApplication().statusBarFrame(out r); ccDeviceOrientation orientation = CCDirector.sharedDirector().deviceOrientation; if (orientation == ccDeviceOrientation.CCDeviceOrientationLandscapeLeft || orientation == ccDeviceOrientation.CCDeviceOrientationLandscapeRight) { s.height -= r.size.width; } else { s.height -= r.size.height; } position = new CCPoint(s.width / 2, s.height / 2); if (item != null) { foreach (var menuItem in item) { this.addChild(menuItem); } } // [self alignItemsVertically]; m_pSelectedItem = null; m_eState = tCCMenuState.kCCMenuStateWaiting; return(true); } return(false); }
protected bool initWithItems(params CCMenuItem[] item) { CCRect cCRect; if (!base.init()) { return(false); } this.m_bIsTouchEnabled = true; CCSize winSize = CCDirector.sharedDirector().getWinSize(); this.m_bIsRelativeAnchorPoint = false; this.anchorPoint = new CCPoint(0.5f, 0.5f); this.contentSize = winSize; CCApplication.sharedApplication().statusBarFrame(out cCRect); ccDeviceOrientation _ccDeviceOrientation = CCDirector.sharedDirector().deviceOrientation; if (_ccDeviceOrientation == ccDeviceOrientation.kCCDeviceOrientationLandscapeLeft || _ccDeviceOrientation == ccDeviceOrientation.kCCDeviceOrientationLandscapeRight) { CCSize cCSize = winSize; cCSize.height = cCSize.height - cCRect.size.width; } else { CCSize cCSize1 = winSize; cCSize1.height = cCSize1.height - cCRect.size.height; } this.position = new CCPoint(winSize.width / 2f, winSize.height / 2f); if (item != null) { CCMenuItem[] cCMenuItemArray = item; for (int i = 0; i < (int)cCMenuItemArray.Length; i++) { this.addChild(cCMenuItemArray[i]); } } this.m_pSelectedItem = null; this.m_eState = tCCMenuState.kCCMenuStateWaiting; return(true); }
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); }
/// <summary> /// initializes a CCMenu with it's items /// </summary> bool initWithItems(params CCMenuItem[] item) { if (base.init()) { this.m_bIsTouchEnabled = true; // menu in the center of the screen CCSize s = CCDirector.sharedDirector().getWinSize(); this.m_bIsRelativeAnchorPoint = false; anchorPoint = new CCPoint(0.5f, 0.5f); this.contentSize = s; // XXX: in v0.7, winSize should return the visible size // XXX: so the bar calculation should be done there CCRect r; CCApplication.sharedApplication().statusBarFrame(out r); ccDeviceOrientation orientation = CCDirector.sharedDirector().deviceOrientation; if (orientation == ccDeviceOrientation.CCDeviceOrientationLandscapeLeft || orientation == ccDeviceOrientation.CCDeviceOrientationLandscapeRight) { s.height -= r.size.width; } else { s.height -= r.size.height; } position = new CCPoint(s.width / 2, s.height / 2); if (item != null) { foreach (var menuItem in item) { this.addChild(menuItem); } } // [self alignItemsVertically]; m_pSelectedItem = null; m_eState = tCCMenuState.kCCMenuStateWaiting; return true; } return false; }
public override void onExit() { if (m_eState == tCCMenuState.kCCMenuStateTrackingTouch) { m_pSelectedItem.unselected(); m_eState = tCCMenuState.kCCMenuStateWaiting; m_pSelectedItem = null; } base.onExit(); }
public override void ccTouchEnded(CCTouch touch, CCEvent ccevent) { Debug.Assert(m_eState == tCCMenuState.kCCMenuStateTrackingTouch, "[Menu ccTouchEnded] -- invalid state"); if (m_pSelectedItem != null) { m_pSelectedItem.unselected(); m_pSelectedItem.activate(); } m_eState = tCCMenuState.kCCMenuStateWaiting; }
/// <summary> /// For phone event handle functions /// </summary> public override bool ccTouchBegan(CCTouch touch, CCEvent ccevent) { if (m_eState != tCCMenuState.kCCMenuStateWaiting || !m_bIsVisible) { return false; } for (CCNode c = this.m_pParent; c != null; c = c.parent) { if (c.visible == false) { return false; } } m_pSelectedItem = this.itemForTouch(touch); if (m_pSelectedItem != null) { m_eState = tCCMenuState.kCCMenuStateTrackingTouch; m_pSelectedItem.selected(); return true; } return false; }