Class cc.ControlButton
- Defined in: CCControlButton.js
- Extends cc.Control
Constructor Attributes | Constructor Name and Description |
---|---|
CCControlButton: Button control for Cocos2D.
|
Method Summary
Class Detail
cc.ControlButton()
CCControlButton: Button control for Cocos2D.
Field Detail
{Boolean}
adjustBackgroundImage
- Indicate whether the background image will be adjusted
{Boolean}
labelAnchor
- The anchor point for the label of the control button
{cc.Size}
preferredSize
- The preferred size of the control button
{Boolean}
zoomOnTouchDown
- Indicate whether the button will be zoomed while touch down
Method Detail
-
<static> {ControlButton} cc.ControlButton.create(label, backgroundSprite, fontSize)
- Parameters:
- label
- backgroundSprite
- fontSize
- Returns:
- {ControlButton}
-
{Boolean} doesAdjustBackgroundImage()Adjust the background image. YES by default. If the property is set to NO, the background will use the prefered size of the background image.
- Returns:
- {Boolean}
-
getBackgroundSpriteForState(state)Returns the background sprite used for a state.
- Parameters:
- {Number} state
- The state that uses the background sprite. Possible values are described in "CCControlState".
-
getPreferredSize()The prefered size of the button, if label is larger it will be expanded.
-
{cc.Color} getTitleColorForState(state)Returns the title color used for a state.
- Parameters:
- {Number} state
- The state that uses the specified color. The values are described in "CCControlState".
- Returns:
- {cc.Color} The color of the title for the specified state.
-
{string} getTitleForState(state)Returns the title used for a state.
- Parameters:
- {Number} state
- The state that uses the title. Possible values are described in "CCControlState".
- Returns:
- {string} The title for the specified state.
-
{cc.Node} getTitleLabelForState(state)Returns the title label used for a state.
- Parameters:
- state
- The state that uses the title label. Possible values are described in "CCControlState".
- Returns:
- {cc.Node} the title label used for a state.
-
{string} getTitleTTFForState(state)return the title TTF filename to use for the specified state.
- Parameters:
- {Number} state
- Returns:
- {string}
-
{Number} getTitleTTFSizeForState(state)return the font size of LabelTTF to use for the specified state
- Parameters:
- {Number} state
- Returns:
- {Number}
-
getZoomOnTouchDown()Adjust the button zooming on touchdown. Default value is YES.
-
isPushed()Flag to know if the button is currently pushed.
-
setBackgroundSpriteForState(sprite, state)Sets the background sprite to use for the specified button state.
- Parameters:
- {Scale9Sprite} sprite
- The background sprite to use for the specified state.
- {Number} state
- The state that uses the specified image. The values are described in "CCControlState".
-
setBackgroundSpriteFrameForState(spriteFrame, state)Sets the background spriteFrame to use for the specified button state.
- Parameters:
- {SpriteFrame} spriteFrame
- The background spriteFrame to use for the specified state.
- {Number} state
- The state that uses the specified image. The values are described in "CCControlState".
-
setMargins(marginH, marginV)set the margins at once (so we only have to do one call of needsLayout)
- Parameters:
- {Number} marginH
- {Number} marginV
-
setTitleBMFontForState(fntFile, state)Sets the font of the label, changes the label to a CCLabelBMFont if necessary.
- Parameters:
- {string} fntFile
- The name of the font to change to
- {Number} state
- The state that uses the specified fntFile. The values are described in "CCControlState".
-
setTitleColorForState(color, state)Sets the color of the title to use for the specified state.
- Parameters:
- {cc.Color} color
- The color of the title to use for the specified state.
- {Number} state
- The state that uses the specified color. The values are described in "CCControlState".
-
setTitleForState(title, state)
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.- Parameters:
- {string} title
- The title string to use for the specified state.
- {Number} state
- The state that uses the specified title. The values are described in "CCControlState".
-
setTitleLabelForState(titleLabel, state)
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.- Parameters:
- {cc.Node} titleLabel
- The title label to use for the specified state.
- {Number} state
- The state that uses the specified title. The values are described in "CCControlState".
-
setTitleTTFForState(fntFile, state)Sets the title TTF filename to use for the specified state.
- Parameters:
- {string} fntFile
- {Number} state
-
setTitleTTFSizeForState(size, state)
- Parameters:
- {Number} size
- {Number} state