public static CCMenuItem itemWithTarget(SelectorProtocol rec, SEL_MenuHandler selector) { CCMenuItem cCMenuItem = new CCMenuItem(); cCMenuItem.initWithTarget(rec, selector); return(cCMenuItem); }
/// <summary> /// Creates a CCMenuItem with a target/selector /// </summary> /// <param name="rec"></param> /// <param name="selector"></param> /// <returns></returns> public static CCMenuItem itemWithTarget(SelectorProtocol rec, SEL_MenuHandler selector) { CCMenuItem pRet = new CCMenuItem(); pRet.initWithTarget(rec, selector); return pRet; }
/// <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 static CCMenuItemToggle itemWithItem(CCMenuItem item) { CCMenuItemToggle cCMenuItemToggle = new CCMenuItemToggle(); cCMenuItemToggle.initWithItem(item); return(cCMenuItemToggle); }
/// <summary> /// The follow methods offered to lua /// creates a menu item with a item /// </summary> public static CCMenuItemToggle itemWithItem(CCMenuItem item) { CCMenuItemToggle pRet = new CCMenuItemToggle(); pRet.initWithItem(item); return(pRet); }
public LayerLevels() { //�ؿ�ѡ��� CCPoint offset = new CCPoint(170, 180); for (int i = 0; i < 4; i++) { for (int j = 0; j < 3; j++) { //�ؿ��İ�ť CCMenuItemSprite level = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("btn_level1.png"), CCSprite.spriteWithSpriteFrameName("btn_level2.png"), this, click_level); CCMenu menu = CCMenu.menuWithItems(level); //λ����������ϵ�UI���� menu.position = CCDirector.sharedDirector().convertToUI(new CCPoint(offset.x + 160 * i, offset.y + 85 * j)); this.addChild(menu); //����һ��MenuItem�������ı����� CCMenuItem menuitem = new CCMenuItem(); //ָ��Arial��������������֤fonts����Arial.spritefont var text = CCLabelTTF.labelWithString((j * 4 + i + 1).ToString(), "Arial", 12); //����ɫָ��Ϊ��ɫ text.Color = new ccColor3B(); menuitem.addChild(text); menu.addChild(menuitem); } } }
/// <summary> /// Creates a CCMenuItem with a target/selector /// </summary> /// <param name="rec"></param> /// <param name="selector"></param> /// <returns></returns> public static CCMenuItem itemWithTarget(SelectorProtocol rec, SEL_MenuHandler selector) { CCMenuItem pRet = new CCMenuItem(); pRet.initWithTarget(rec, selector); return(pRet); }
/// <summary> /// initializes a menu item with a item /// </summary> public bool initWithItem(CCMenuItem item) { base.initWithTarget(null, null); this.m_pSubItems = new List <CCMenuItem>(); m_pSubItems.Add(item); this.SelectedIndex = 0; return(true); }
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 bool initWithTarget(SelectorProtocol target, SEL_MenuHandler selector, CCMenuItem[] items) { base.initWithTarget(target, selector); this.m_pSubItems = new List <CCMenuItem>(); CCMenuItem[] cCMenuItemArray = items; for (int i = 0; i < (int)cCMenuItemArray.Length; i++) { CCMenuItem cCMenuItem = cCMenuItemArray[i]; this.m_pSubItems.Add(cCMenuItem); } this.SelectedIndex = 0; 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 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 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 MenuLayer3() { CCMenuItemFont.FontName = "arial"; CCMenuItemFont.FontSize = 28; CCLabelBMFont label = CCLabelBMFont.Create("Enable AtlasItem", "fonts/bitmapFontTest3.fnt"); CCMenuItemLabel item1 = CCMenuItemLabel.Create(label, this.menuCallback2); CCMenuItemFont item2 = CCMenuItemFont.Create("--- Go Back ---", this.menuCallback); CCSprite spriteNormal = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23)); CCSprite spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23)); CCSprite spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23)); CCMenuItemSprite item3 = new CCMenuItemSprite(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback3); m_disabledItem = item3; m_disabledItem.Enabled = false; CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(0, 0); CCSize s = CCDirector.SharedDirector.WinSize; item1.Position = new CCPoint(s.Width / 2 - 150, s.Height / 2); item2.Position = new CCPoint(s.Width / 2 - 200, s.Height / 2); item3.Position = new CCPoint(s.Width / 2, s.Height / 2 - 100); CCJumpBy jump = new CCJumpBy (3, new CCPoint(400, 0), 50, 4); item2.RunAction(new CCRepeatForever ( (CCActionInterval)(CCSequence.FromActions(jump, jump.Reverse())) ) ); CCActionInterval spin1 = new CCRotateBy (3, 360); CCActionInterval spin2 = (CCActionInterval)(spin1.Copy()); CCActionInterval spin3 = (CCActionInterval)(spin1.Copy()); item1.RunAction(new CCRepeatForever (spin1)); item2.RunAction(new CCRepeatForever (spin2)); item3.RunAction(new CCRepeatForever (spin3)); AddChild(menu); }
public MenuLayer3() { CCMenuItemFont.FontName = "Arial"; CCMenuItemFont.FontSize = 28; CCLabelBMFont label = CCLabelBMFont.labelWithString("Enable AtlasItem", "fonts/fnt/bitmapFontTest3"); CCMenuItemLabel item1 = CCMenuItemLabel.itemWithLabel(label, this, this.menuCallback2); CCMenuItemFont item2 = CCMenuItemFont.itemFromString("--- Go Back ---", this, this.menuCallback); CCSprite spriteNormal = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 2, 115, 23)); CCSprite spriteSelected = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 1, 115, 23)); CCSprite spriteDisabled = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 0, 115, 23)); CCMenuItemSprite item3 = CCMenuItemSprite.itemFromNormalSprite(spriteNormal, spriteSelected, spriteDisabled, this, this.menuCallback3); m_disabledItem = item3; m_disabledItem.Enabled = false; CCMenu menu = CCMenu.menuWithItems(item1, item2, item3); menu.position = new CCPoint(0, 0); CCSize s = CCDirector.sharedDirector().getWinSize(); item1.position = new CCPoint(s.width / 2 - 150, s.height / 2); item2.position = new CCPoint(s.width / 2 - 200, s.height / 2); item3.position = new CCPoint(s.width / 2, s.height / 2 - 100); CCJumpBy jump = CCJumpBy.actionWithDuration(3, new CCPoint(400, 0), 50, 4); item2.runAction(CCRepeatForever.actionWithAction( (CCActionInterval)(CCSequence.actions(jump, jump.reverse())) ) ); CCActionInterval spin1 = CCRotateBy.actionWithDuration(3, 360); CCActionInterval spin2 = (CCActionInterval)(spin1.copy()); CCActionInterval spin3 = (CCActionInterval)(spin1.copy()); item1.runAction(CCRepeatForever.actionWithAction(spin1)); item2.runAction(CCRepeatForever.actionWithAction(spin2)); item3.runAction(CCRepeatForever.actionWithAction(spin3)); addChild(menu); }
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> /// Handles the button press event to track which focused menu item will get the activation /// </summary> /// <param name="backButton"></param> /// <param name="startButton"></param> /// <param name="systemButton"></param> /// <param name="aButton"></param> /// <param name="bButton"></param> /// <param name="xButton"></param> /// <param name="yButton"></param> /// <param name="leftShoulder"></param> /// <param name="rightShoulder"></param> /// <param name="player"></param> protected override void OnGamePadButtonUpdate(CCGamePadButtonStatus backButton, CCGamePadButtonStatus startButton, CCGamePadButtonStatus systemButton, CCGamePadButtonStatus aButton, CCGamePadButtonStatus bButton, CCGamePadButtonStatus xButton, CCGamePadButtonStatus yButton, CCGamePadButtonStatus leftShoulder, CCGamePadButtonStatus rightShoulder, Microsoft.Xna.Framework.PlayerIndex player) { base.OnGamePadButtonUpdate(backButton, startButton, systemButton, aButton, bButton, xButton, yButton, leftShoulder, rightShoulder, player); if (!HasFocus) { return; } if (backButton == CCGamePadButtonStatus.Pressed || aButton == CCGamePadButtonStatus.Pressed || bButton == CCGamePadButtonStatus.Pressed || xButton == CCGamePadButtonStatus.Pressed || yButton == CCGamePadButtonStatus.Pressed || leftShoulder == CCGamePadButtonStatus.Pressed || rightShoulder == CCGamePadButtonStatus.Pressed) { CCMenuItem item = ItemWithFocus; item.Selected(); m_pSelectedItem = item; m_eState = CCMenuState.TrackingTouch; } else if (backButton == CCGamePadButtonStatus.Released || aButton == CCGamePadButtonStatus.Released || bButton == CCGamePadButtonStatus.Released || xButton == CCGamePadButtonStatus.Released || yButton == CCGamePadButtonStatus.Released || leftShoulder == CCGamePadButtonStatus.Released || rightShoulder == CCGamePadButtonStatus.Released) { if (m_eState == CCMenuState.TrackingTouch) { // Now we are selecting the menu item CCMenuItem item = ItemWithFocus; if (item != null && m_pSelectedItem == item) { // Activate this item item.Unselected(); item.Activate(); m_eState = CCMenuState.Waiting; m_pSelectedItem = null; } } } }
public override void onExit() { if (m_eState == tCCMenuState.kCCMenuStateTrackingTouch) { m_pSelectedItem.unselected(); m_eState = tCCMenuState.kCCMenuStateWaiting; m_pSelectedItem = null; } base.onExit(); }
/// <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 static CCMenuItemToggle Create(CCMenuItem item) { var pRet = new CCMenuItemToggle(); pRet.InitWithItem(item); return pRet; }
public void AddSubItem(CCMenuItem item) { m_pSubItems.Add(item); }
public override void TouchMoved(CCTouch touch, CCEvent e) { Debug.Assert(m_eState == CCMenuState.TrackingTouch, "[Menu TouchMoved] -- invalid state"); CCMenuItem currentItem = ItemForTouch(touch); if (currentItem != m_pSelectedItem) { if (m_pSelectedItem != null) { m_pSelectedItem.Unselected(); } m_pSelectedItem = currentItem; if (m_pSelectedItem != null) { m_pSelectedItem.Selected(); } } }
public bool InitWithItem(CCMenuItem item) { base.InitWithTarget(null); m_pSubItems = new List<CCMenuItem>(); m_pSubItems.Add(item); m_uSelectedIndex = int.MaxValue; SelectedIndex = 0; return true; }
public bool InitWithTarget(SEL_MenuHandler selector, CCMenuItem[] items) { base.InitWithTarget(selector); m_pSubItems = new List<CCMenuItem>(); foreach (CCMenuItem item in items) { m_pSubItems.Add(item); } m_uSelectedIndex = int.MaxValue; SelectedIndex = 0; return true; }
public static CCMenu menuWithItem(CCMenuItem item) { return(CCMenu.menuWithItems(new CCMenuItem[] { item })); }
public CCMenu() { m_cOpacity = 0; m_pSelectedItem = null; }
public CCMenu() { this.m_cOpacity = 0; this.m_pSelectedItem = null; }
/// <summary> /// creates a CCMenu with it's item, then use addChild() to add /// other items. It is used for script, it can't init with undetermined /// number of variables. /// </summary> public static CCMenu menuWithItem(CCMenuItem item) { return(menuWithItems(item)); }
public override bool TouchBegan(CCTouch touch, CCEvent e) { if (m_eState != CCMenuState.Waiting || !m_bIsVisible || !m_bEnabled) { return false; } for (CCNode c = m_pParent; c != null; c = c.Parent) { if (c.Visible == false) { return false; } } m_pSelectedItem = ItemForTouch(touch); if (m_pSelectedItem != null) { m_eState = CCMenuState.TrackingTouch; m_pSelectedItem.Selected(); return true; } return false; }
/// <summary> /// The follow methods offered to lua /// creates a menu item with a item /// </summary> public static CCMenuItemToggle itemWithItem(CCMenuItem item) { CCMenuItemToggle pRet = new CCMenuItemToggle(); pRet.initWithItem(item); return pRet; }
/// <summary> /// add more menu item /// </summary> public void addSubItem(CCMenuItem item) { this.m_pSubItems.Add(item); }
/// <summary> /// creates a CCMenu with it's item, then use addChild() to add /// other items. It is used for script, it can't init with undetermined /// number of variables. /// </summary> public static CCMenu menuWithItem(CCMenuItem item) { return menuWithItems(item); }
public override void OnExit() { if (m_eState == CCMenuState.TrackingTouch) { m_pSelectedItem.Unselected(); m_eState = CCMenuState.Waiting; m_pSelectedItem = null; } foreach (CCMenuItem item in _Items) { CCFocusManager.Instance.Remove(item); } base.OnExit(); }
/// <summary> /// initializes a menu item from a list of items with a target selector /// </summary> public bool initWithTarget(SelectorProtocol target, SEL_MenuHandler selector, CCMenuItem[] items) { base.initWithTarget(target, selector); this.m_pSubItems = new List<CCMenuItem>(); foreach (var item in items) { m_pSubItems.Add(item); } this.SelectedIndex = 0; 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; }
/// <summary> /// The position of the menu is set to the center of the main screen /// </summary> /// <param name="items"></param> /// <returns></returns> private bool InitWithArray(params CCMenuItem[] items) { if (_Items.Count > 0) { List<CCMenuItem> copy = new List<CCMenuItem>(_Items); foreach (CCMenuItem i in copy) { RemoveChild(i, false); } } if (base.Init()) { TouchEnabled = true; m_bEnabled = true; // menu in the center of the screen CCSize s = CCDirector.SharedDirector.WinSize; IgnoreAnchorPointForPosition = true; AnchorPoint = new CCPoint(0.5f, 0.5f); ContentSize = s; Position = (new CCPoint(s.Width / 2, s.Height / 2)); if (items != null) { int z = 0; foreach (CCMenuItem item in items) { AddChild(item, z); z++; } } // [self alignItemsVertically]; m_pSelectedItem = null; m_eState = CCMenuState.Waiting; return true; } return false; }
/// <summary> /// initializes a menu item with a item /// </summary> public bool initWithItem(CCMenuItem item) { base.initWithTarget(null, null); this.m_pSubItems = new List<CCMenuItem>(); m_pSubItems.Add(item); this.SelectedIndex = 0; return true; }