/** * Sets the background spriteFrame to use for the specified button state. * * @param spriteFrame The background spriteFrame to use for the specified state. * @param state The state that uses the specified image. The values are described * in "CCControlState". */ public virtual void SetBackgroundSpriteFrameForState(CCSpriteFrame spriteFrame, CCControlState state) { CCScale9Sprite sprite = new CCScale9SpriteFrame(spriteFrame); SetBackgroundSpriteForState(sprite, state); }
/** * Returns the background sprite used for a state. * * @param state The state that uses the background sprite. Possible values are * described in "CCControlState". */ public virtual CCScale9Sprite GetBackgroundSpriteForState(CCControlState state) { CCScale9Sprite backgroundSprite; if (m_backgroundSpriteDispatchTable.TryGetValue(state, out backgroundSprite)) { return backgroundSprite; } if (m_backgroundSpriteDispatchTable.TryGetValue(CCControlState.Normal, out backgroundSprite)) { return backgroundSprite; } return null; }
/** * Sets the background sprite to use for the specified button state. * * @param sprite The background sprite to use for the specified state. * @param state The state that uses the specified image. The values are described * in "CCControlState". */ public virtual void SetBackgroundSpriteForState(CCScale9Sprite sprite, CCControlState state) { CCSize oldPreferredSize = m_preferredSize; CCScale9Sprite previousBackgroundSprite; if (m_backgroundSpriteDispatchTable.TryGetValue(state, out previousBackgroundSprite)) { RemoveChild(previousBackgroundSprite, true); m_backgroundSpriteDispatchTable.Remove(state); } m_backgroundSpriteDispatchTable.Add(state, sprite); sprite.Visible = false; sprite.AnchorPoint = new CCPoint(0.5f, 0.5f); AddChild(sprite); if (m_preferredSize.Width != 0 || m_preferredSize.Height != 0) { if (oldPreferredSize.Equals(m_preferredSize)) { // Force update of preferred size sprite.PreferredSize = new CCSize(oldPreferredSize.Width + 1, oldPreferredSize.Height + 1); } sprite.PreferredSize = m_preferredSize; } // If the current state if equal to the given state we update the layout if (State == state) { NeedsLayout(); } }
/** * Sets the font of the label, changes the label to a CCLabelBMFont if neccessary. * @param fntFile The name of the font to change to * @param state The state that uses the specified fntFile. The values are described * in "CCControlState". */ public virtual void SetTitleBmFontForState(string fntFile, CCControlState state) { string title = GetTitleForState(state); if (title == null) { title = String.Empty; } SetTitleLabelForState(new CCLabelBMFont(title, fntFile), state); }
public virtual string GetTitleBmFontForState(CCControlState state) { var label = (ICCLabelProtocol) GetTitleLabelForState(state); var labelBmFont = label as CCLabelBMFont; if (labelBmFont != null) { return labelBmFont.FntFile; } return String.Empty; }
public virtual void SetTitleTtfSizeForState(float size, CCControlState state) { var label = (ICCLabelProtocol) GetTitleLabelForState(state); if (label != null) { var labelTtf = label as CCLabelTTF; if (labelTtf != null) { labelTtf.FontSize = size; } } }
public virtual float GetTitleTtfSizeForState(CCControlState state) { var labelTtf = GetTitleLabelForState(state) as CCLabelTTF; if (labelTtf != null) { return labelTtf.FontSize; } return 0; }
/** * Sets the title label to use for the specified state. * If a property is not specified for a state, the default is to use * the CCButtonStateNormal value. * * @param title The title label to use for the specified state. * @param state The state that uses the specified title. The values are described * in "CCControlState". */ public virtual void SetTitleLabelForState(CCNode titleLabel, CCControlState state) { CCNode previousLabel; if (m_titleLabelDispatchTable.TryGetValue(state, out previousLabel)) { RemoveChild(previousLabel, true); m_titleLabelDispatchTable.Remove(state); } m_titleLabelDispatchTable.Add(state, titleLabel); titleLabel.Visible = false; titleLabel.AnchorPoint = new CCPoint(0.5f, 0.5f); AddChild(titleLabel, 1); // If the current state if equal to the given state we update the layout if (State == state) { NeedsLayout(); } }
public virtual string GetTitleTtfForState(CCControlState state) { var label = (ICCLabelProtocol) GetTitleLabelForState(state); var labelTtf = label as CCLabelTTF; if (labelTtf != null) { return labelTtf.FontName; } return String.Empty; }
/** * Sets the color of the title to use for the specified state. * * @param color The color of the title to use for the specified state. * @param state The state that uses the specified color. The values are described * in "CCControlState". */ public virtual void SetTitleColorForState(CCColor3B color, CCControlState state) { if (m_titleColorDispatchTable.ContainsKey(state)) { m_titleColorDispatchTable.Remove(state); } m_titleColorDispatchTable.Add(state, color); // If the current state if equal to the given state we update the layout if (State == state) { NeedsLayout(); } }
/** * Returns the title label used for a state. * * @param state The state that uses the title label. Possible values are described * in "CCControlState". */ public virtual CCNode GetTitleLabelForState(CCControlState state) { CCNode titleLabel; if (m_titleLabelDispatchTable.TryGetValue(state, out titleLabel)) { return titleLabel; } if (m_titleLabelDispatchTable.TryGetValue(CCControlState.Normal, out titleLabel)) { return titleLabel; } return null; }
/** * Returns the title color used for a state. * * @param state The state that uses the specified color. The values are described * in "CCControlState". * * @return The color of the title for the specified state. */ public virtual CCColor3B GetTitleColorForState(CCControlState state) { if (m_titleColorDispatchTable != null) { CCColor3B color; if (m_titleColorDispatchTable.TryGetValue(state, out color)) { return color; } if (m_titleColorDispatchTable.TryGetValue(CCControlState.Normal, out color)) { return color; } } return CCTypes.CCWhite; }
/** * Sets the title string to use for the specified state. * If a property is not specified for a state, the default is to use * the CCButtonStateNormal value. * * @param title The title string to use for the specified state. * @param state The state that uses the specified title. The values are described * in "CCControlState". */ public virtual void SetTitleForState(string title, CCControlState state) { if (m_titleDispatchTable.ContainsKey(state)) { m_titleDispatchTable.Remove(state); } if (!String.IsNullOrEmpty(title)) { m_titleDispatchTable.Add(state, title); } // If the current state if equal to the given state we update the layout if (State == state) { NeedsLayout(); } }
/** * Returns the title used for a state. * * @param state The state that uses the title. Possible values are described in * "CCControlState". * * @return The title for the specified state. */ public virtual string GetTitleForState(CCControlState state) { if (m_titleDispatchTable != null) { string title; if (m_titleDispatchTable.TryGetValue(state, out title)) { return title; } if (m_titleDispatchTable.TryGetValue(CCControlState.Normal, out title)) { return title; } } return String.Empty; }
public override bool Init() { if (base.Init()) { //this->setTouchEnabled(true); //m_bIsTouchEnabled=true; // Initialise instance variables m_eState = CCControlState.Normal; Enabled = true; Selected = false; Highlighted = false; // Set the touch dispatcher priority by default to 1 DefaultTouchPriority = 1; // Initialise the tables m_pDispatchTable = new Dictionary<CCControlEvent, RawList<CCInvocation>>(); return true; } return false; }
public override bool Init() { if (base.Init()) { _state = CCControlState.Normal; Enabled = true; Selected = false; Highlighted = false; TouchMode = CCTouchMode.OneByOne; // So we use a targeted delegate. // Initialise the tables _dispatchTable = new Dictionary<CCControlEvent, CCRawList<CCInvocation>>(); return true; } return false; }