/** Creates and return a button with a default background and title color. */ public CCControlButton standardButtonWithTitle(string title) { /** Creates and return a button with a default background and title color. */ var backgroundButton = new CCScale9SpriteFile("extensions/button"); var backgroundHighlightedButton = new CCScale9SpriteFile("extensions/buttonHighlighted"); var titleButton = new CCLabelTTF(title, "Arial", 30); titleButton.Color = new CCColor3B(159, 168, 176); var button = new CCControlButton(titleButton, backgroundButton); button.SetBackgroundSpriteForState(backgroundHighlightedButton, CCControlState.Highlighted); button.SetTitleColorForState(CCTypes.CCWhite, CCControlState.Highlighted); return button; }
public new static CCControlButton Create() { var pControlButton = new CCControlButton(); return pControlButton; }
public override bool Init() { if (base.Init()) { CCSize screenSize = CCDirector.SharedDirector.WinSize; // Add a label in which the button events will be displayed setDisplayValueLabel(new CCLabelTTF("No Event", "Arial", 32)); m_pDisplayValueLabel.AnchorPoint = new CCPoint(0.5f, -1); m_pDisplayValueLabel.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f); AddChild(m_pDisplayValueLabel, 1); // Add the button var backgroundButton = new CCScale9SpriteFile("extensions/button"); var backgroundHighlightedButton = new CCScale9SpriteFile("extensions/buttonHighlighted"); var titleButton = new CCLabelTTF("Touch Me!", "Arial", 30); titleButton.Color = new CCColor3B(159, 168, 176); var controlButton = new CCControlButton(titleButton, backgroundButton); controlButton.SetBackgroundSpriteForState(backgroundHighlightedButton, CCControlState.Highlighted); controlButton.SetTitleColorForState(CCTypes.CCWhite, CCControlState.Highlighted); controlButton.AnchorPoint = new CCPoint(0.5f, 1); controlButton.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f); AddChild(controlButton, 1); // Add the black background var background = new CCScale9SpriteFile("extensions/buttonBackground"); background.ContentSize = new CCSize(300, 170); background.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f); AddChild(background); // Sets up event handlers controlButton.AddTargetWithActionForControlEvent(this, touchDownAction, CCControlEvent.TouchDown); controlButton.AddTargetWithActionForControlEvent(this, touchDragInsideAction, CCControlEvent.TouchDragInside); controlButton.AddTargetWithActionForControlEvent(this, touchDragOutsideAction, CCControlEvent.TouchDragOutside); controlButton.AddTargetWithActionForControlEvent(this, touchDragEnterAction, CCControlEvent.TouchDragEnter); controlButton.AddTargetWithActionForControlEvent(this, touchDragExitAction, CCControlEvent.TouchDragExit); controlButton.AddTargetWithActionForControlEvent(this, touchUpInsideAction, CCControlEvent.TouchUpInside); controlButton.AddTargetWithActionForControlEvent(this, touchUpOutsideAction, CCControlEvent.TouchUpOutside); controlButton.AddTargetWithActionForControlEvent(this, touchCancelAction, CCControlEvent.TouchCancel); return true; } return false; }
public CCControlButton standardButtonWithTitle(string title) { _TheTexture = CCTextureCache.SharedTextureCache.AddImage("extensions/button"); /** Creates and return a button with a default background and title color. */ var backgroundButton = new CCScale9SpriteFile("extensions/button"); backgroundButton.PreferredSize = new CCSize(55, 55); // Set the prefered size var backgroundHighlightedButton = new CCScale9SpriteFile("extensions/buttonHighlighted"); backgroundHighlightedButton.PreferredSize = new CCSize(55, 55); // Set the prefered size var titleButton = new CCLabelTTF(title, "Arial", 30); titleButton.Color = new CCColor3B(159, 168, 176); var button = new CCControlButton(titleButton, backgroundButton); button.SetBackgroundSpriteForState(backgroundHighlightedButton, CCControlState.Highlighted); button.SetTitleColorForState(CCTypes.CCWhite, CCControlState.Highlighted); return button; }
public new static CCControlButton Create() { var pControlButton = new CCControlButton(); return(pControlButton); }