Class ccui.Button
- Defined in: UIButton.js
- Extends ccui.Widget
Constructor Attributes | Constructor Name and Description |
---|---|
The button controls of Cocos UI.
|
Method Summary
Class Detail
ccui.Button()
The button controls of Cocos UI.
Field Detail
<static> <constant>
ccui.Button.DISABLED_RENDERER_ZORDER
The disabled renderer's zOrder value of ccui.Button.
<static> <constant>
ccui.Button.NORMAL_RENDERER_ZORDER
The normal renderer's zOrder value of ccui.Button.
<static> <constant>
ccui.Button.PRESSED_RENDERER_ZORDER
The pressed renderer's zOrder value ccui.Button.
{Boolean}
pressedActionEnabled
- Indicate whether button has zoom effect when clicked
<static> <constant>
ccui.Button.TITLE_RENDERER_ZORDER
The title renderer's zOrder value of ccui.Button.
{String}
titleFont
- The content string font of the button title
{cc.Color}
titleFontColor
- The content string font color of the button title
{String}
titleFontName
- The content string font name of the button title
{Number}
titleFontSize
- The content string font size of the button title
{String}
titleText
- The content string of the button title
<static> <constant>
ccui.Button.ZOOM_ACTION_TIME_STEP
the zoom action time step of ccui.Button
Method Detail
-
allocates and initializes a UIButton.
- Parameters:
- {string} normalImage Optional
- normal state texture name
- {string} selectedImage Optional
- selected state texture name
- {string} disableImage Optional
- disabled state texture name
- {string} texType Optional
- Deprecated:
- since v3.0, please use new ccui.Button() instead.
- Returns:
- {ccui.Button}
-
ctor(normalImage, selectedImage, disableImage, texType)Allocates and initializes a UIButton. Constructor of ccui.Button. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
// example var uiButton = new ccui.Button();
- Parameters:
- {String} normalImage
- {String} selectedImage Optional, Default: ""
- {String} disableImage Optional, Default: ""
- {Number} texType Optional, Default: ccui.Widget.LOCAL_TEXTURE
-
{cc.Rect} getCapInsetsDisabledRenderer()Returns disable renderer cap insets.
- Returns:
- {cc.Rect}
-
{cc.Rect} getCapInsetsNormalRenderer()Returns normal renderer cap insets.
- Returns:
- {cc.Rect}
-
{cc.Rect} getCapInsetsPressedRenderer()Returns pressed renderer cap insets.
- Returns:
- {cc.Rect}
-
{string} getDescription()Returns the "class name" of widget.
- Returns:
- {string}
-
{cc.Size} getNormalTextureSize()Returns the normalize of texture size
- Since:
- v3.3
- Returns:
- {cc.Size}
-
{cc.Color} getTitleColor()Returns title color of ccui.Button
- Returns:
- {cc.Color}
-
{String} getTitleFontName()Gets title fontName of ccui.Button.
- Returns:
- {String}
-
{Number} getTitleFontSize()Returns title fontSize of ccui.Button.
- Returns:
- {Number}
-
{cc.LabelTTF} getTitleRenderer()Get the title renderer. title ttf object.
- Returns:
- {cc.LabelTTF}
-
{String} getTitleText()Returns title text of ccui.Button
- Returns:
- {String} text
-
{cc.Node} getVirtualRenderer()Gets the Virtual Renderer of widget.
- Returns:
- {cc.Node}
-
{cc.Size} getVirtualRendererSize()Returns the renderer size.
- Returns:
- {cc.Size}
-
{number} getZoomScale()Returns a zoom scale
- Since:
- v3.2
- Returns:
- {number}
-
ignoreContentAdaptWithSize(ignore)Sets whether ignore the widget size
- Parameters:
- {Boolean} ignore
- true that widget will ignore it's size, use texture size, false otherwise. Default value is true.
-
{boolean} init(normalImage, selectedImage, disableImage, texType)Initializes a button. please do not call this function by yourself, you should pass the parameters to constructor to initialize it.
- Parameters:
- {String} normalImage
- {String} selectedImage Optional, Default: ""
- {String} disableImage Optional, Default: ""
- {Number} texType Optional, Default: ccui.Widget.LOCAL_TEXTURE
- Returns:
- {boolean}
-
{Boolean} isScale9Enabled()Returns button is using scale9 renderer or not.
- Returns:
- {Boolean}
-
loadTextureDisabled(disabled, texType)Load dark state texture for button.
- Parameters:
- {String} disabled
- disabled state of texture's filename.
- {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType
-
loadTextureNormal(normal, texType)Load normal state texture for button.
- Parameters:
- {String} normal
- normal state of texture's filename.
- {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType
-
loadTexturePressed(selected, texType)Load selected state texture for button.
- Parameters:
- {String} selected
- selected state of texture's filename.
- {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType
-
loadTextures(normal, selected, disabled, texType)Load textures for button.
- Parameters:
- {String} normal
- normal state of texture's filename.
- {String} selected
- selected state of texture's filename.
- {String} disabled
- disabled state of texture's filename.
- {ccui.Widget.LOCAL_TEXTURE|ccui.Widget.PLIST_TEXTURE} texType
-
setCapInsets(capInsets)Sets capinsets for button, if button is using scale9 renderer.
- Parameters:
- {cc.Rect} capInsets
-
setCapInsetsDisabledRenderer(capInsets)Sets capinsets for button, if button is using scale9 renderer.
- Parameters:
- {cc.Rect} capInsets
-
setCapInsetsNormalRenderer(capInsets)Sets capinsets for button, if button is using scale9 renderer.
- Parameters:
- {cc.Rect} capInsets
-
setCapInsetsPressedRenderer(capInsets)Sets capinsets for button, if button is using scale9 renderer.
- Parameters:
- {cc.Rect} capInsets
-
setPressedActionEnabled(enabled)Changes if button can be clicked zoom effect.
- Parameters:
- {Boolean} enabled
-
setScale9Enabled(able)Sets if button is using scale9 renderer.
- Parameters:
- {Boolean} able
- true that using scale9 renderer, false otherwise.
-
setTitleColor(color)Sets title color to ccui.Button.
- Parameters:
- {cc.Color} color
-
setTitleFontName(fontName)Sets title fontName to ccui.Button.
- Parameters:
- {String} fontName
-
setTitleFontSize(size)Sets title fontSize to ccui.Button
- Parameters:
- {cc.Size} size
-
setTitleText(text)Sets title text to ccui.Button
- Parameters:
- {String} text
-
setZoomScale(scale)When user pressed the button, the button will zoom to a scale. The final scale of the button equals (button original scale + _zoomScale)
- Parameters:
- scale
- Since:
- v3.2