public static MGMenuItem ItemWithTarget(ISelectorProtocol rec, SelMenuHandler selector) { var pRet = new MGMenuItem(); pRet.InitWithTarget(rec, selector); return pRet; }
public MGMenu() { m_cOpacity = 0; m_pSelectedItem = null; IsTouchEnable = true; }
bool initWithItems(params MGMenuItem[] item) { //if (base.init()) //{ //this.m_bIsTouchEnabled = true; // menu in the center of the screen Vector2 s = new Vector2(MGDirector.SharedDirector().ScreenWidth, MGDirector.SharedDirector().ScreenHeight); //this.m_bIsRelativeAnchorPoint = false; //Anchor = new Vector2(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 Rectangle 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 bool TouchesMoved(MouseState touch, Point point) { //Debug.Assert(State == MGMenuState.MenuStateTrackingTouch, "[Menu ccTouchMoved] -- invalid state"); MGMenuItem 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(); } } return true; }
public override bool TouchesBegan(Microsoft.Xna.Framework.Input.MouseState touch, Point point) { //if (!CanClick) //{ // return false; //} if (State != MGMenuState.MenuStateWaiting || !Visible) { return false; } for (MGNode c = this.Parent; c != null; c = c.Parent) { if (c.Visible == false) { return false; } } m_pSelectedItem = this.ItemForTouch(touch); if (m_pSelectedItem != null) { State = MGMenuState.MenuStateTrackingTouch; m_pSelectedItem.selected(); return true; } return false; }