public static CCScale9Sprite CreateWithSpriteFrameName(string spriteFrameName) { var pReturn = new CCScale9Sprite(); pReturn.InitWithSpriteFrameName(spriteFrameName); return pReturn; }
public CCScale9Sprite ResizableSpriteWithCapInsets(CCRect capInsets) { var pReturn = new CCScale9Sprite(); pReturn.InitWithBatchNode(scale9Image, m_spriteRect, capInsets); return pReturn; }
public static new CCScale9Sprite Create() { var pReturn = new CCScale9Sprite(); return pReturn; }
public static CCScale9Sprite CreateWithSpriteFrameName(string spriteFrameName, CCRect capInsets) { var pReturn = new CCScale9Sprite(); pReturn.InitWithSpriteFrameName(spriteFrameName, capInsets); return pReturn; }
public static CCScale9Sprite Create(CCRect capInsets, string file) { var pReturn = new CCScale9Sprite(); pReturn.InitWithFile(file, capInsets); return pReturn; }
public static CCScale9Sprite Create(string file) { var pReturn = new CCScale9Sprite(); pReturn.InitWithFile(file); return pReturn; }
/** * 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(); } }
protected virtual bool InitWithBackgroundSprite(CCScale9Sprite sprite) { CCLabelTTF label = new CCLabelTTF("", "arial", 30); return InitWithLabelAndBackgroundSprite(label, sprite); }
public CCControlButton(CCScale9Sprite sprite) { InitWithBackgroundSprite(sprite); }
public CCControlButton(CCNode label, CCScale9Sprite backgroundSprite) { InitWithLabelAndBackgroundSprite(label, backgroundSprite); }
public virtual bool InitWithLabelAndBackgroundSprite(CCNode node, CCScale9Sprite backgroundSprite) { if (base.Init()) { Debug.Assert(node != null, "Label must not be nil."); var label = node as ICCLabelProtocol; var rgbaLabel = node as ICCRGBAProtocol; Debug.Assert(backgroundSprite != null, "Background sprite must not be nil."); Debug.Assert(label != null || rgbaLabel != null || backgroundSprite != null); m_bParentInited = true; // Initialize the button state tables m_titleDispatchTable = new Dictionary<CCControlState, string>(); m_titleColorDispatchTable = new Dictionary<CCControlState, CCColor3B>(); m_titleLabelDispatchTable = new Dictionary<CCControlState, CCNode>(); m_backgroundSpriteDispatchTable = new Dictionary<CCControlState, CCScale9Sprite>(); TouchEnabled = true; m_isPushed = false; m_zoomOnTouchDown = true; m_currentTitle = null; // Adjust the background image by default SetAdjustBackgroundImage(true); PreferredSize = CCSize.Zero; // Zooming button by default m_zoomOnTouchDown = true; // Set the default anchor point IgnoreAnchorPointForPosition = false; AnchorPoint = new CCPoint(0.5f, 0.5f); // Set the nodes TitleLabel = node; BackgroundSprite = backgroundSprite; // Set the default color and opacity Color = new CCColor3B(255, 255, 255); Opacity = 255; IsOpacityModifyRGB = true; // Initialize the dispatch table string tempString = label.Label; //tempString->autorelease(); SetTitleForState(tempString, CCControlState.Normal); SetTitleColorForState(rgbaLabel.Color, CCControlState.Normal); SetTitleLabelForState(node, CCControlState.Normal); SetBackgroundSpriteForState(backgroundSprite, CCControlState.Normal); LabelAnchorPoint = new CCPoint(0.5f, 0.5f); NeedsLayout(); return true; } //couldn't init the CCControl return false; }
public static CCControlButton Create(CCScale9Sprite sprite) { var pRet = new CCControlButton(); pRet.InitWithBackgroundSprite(sprite); return pRet; }
public static CCControlButton Create(CCNode label, CCScale9Sprite backgroundSprite) { var pRet = new CCControlButton(); pRet.InitWithLabelAndBackgroundSprite(label, backgroundSprite); return pRet; }