Cocos Code Research (+) Widget sub-category button learning notes

Source: Internet
Author: User

Theoretical basis

Represents a button component. Buttons can be pressed, or clicked, and after being pressed or clicked, the user can specify an action to execute and inherit from the Widget.

Code section

Static Button * Create ()
Creates an empty button.

Static Button * Create (const std::string &normalimage,//the name of the normal state texture.
Const std::string &selectedimage= "",//Selected state texture name.
Const std::string &disableimage= "",//disables the name of the state texture.
Texturerestype textype=texturerestype::local)
Creates a button with a custom texture.

void Loadtextures (const std::string &normal,
Const std::string &selected, const std::string &disabled= "",
Texturerestype textype=texturerestype::local)
Loads the texture of the button.

//texture-related
void Loadtexturenormal (const std::string &normal,
Texturerestype textype=texturerestype:: LOCAL)
Loads the texture of the button's normal state.

void loadtexturepressed (const std::string &selected,
Texturerestype textype=texturerestype::local) The
Load button selects the state texture.

void loadtexturedisabled (const std::string &disabled,
Texturerestype textype=texturerestype::local) The
Load button disables the state of the texture.

Related to button text
void Settitletext (const std::string &text)
Change the contents of the button's caption.

Const std::string Gettitletext () const
Query button header content.

void Settitlecolor (const color3b &color)
Change the color of the caption of the button.

COLOR3B Gettitlecolor () const
The color of the query button caption.

void Settitlefontsize (float size)
Change the font size of the caption of the button

float gettitlefontsize () const
Query the font size of the button caption

void Settitlefontname (const std::string &fontname)
Change the font name of the caption of the button

Const std::string Gettitlefontname () const
Font name for the caption of the query button

void Settitlealignment (Texthalignment halignment)
Set the horizontal alignment of the caption's text

Related to nine technology
void Setcapinsets (const Rect &capinsets)
Sets the capinsets of the button. This capinset affects all nine Gongge renderers of the button and only takes effect after calling "setscale9enabled (True)"

void Setcapinsetsnormalrenderer (const Rect &capinsets)
Set the capinsets of the button, only the normal state of the nine Gongge renderer will be affected.

Const Rect & Getcapinsetsnormalrenderer () const
Returns the capinsets of the nine Gongge renderer for the normal state.

void Setcapinsetspressedrenderer (const Rect &capinsets)
The capinsets of the button is set, and only the nine Gongge renderer with the pressed state will be affected.

Const Rect & Getcapinsetspressedrenderer () const
Returns the capinsets of the nine Gongge renderer in the pressed state

void Setcapinsetsdisabledrenderer (const Rect &capinsets)
Sets the capinsets of the button, and only the disabled state of the nine Gongge renderer is affected.

Const Rect & Getcapinsetsdisabledrenderer () const
Returns the capinsets of the nine Gongge renderer for the disabled state.

virtual void setscale9enabled (bool enable)
Enable nine Gongge rendering

BOOL Isscale9enabled () const
Whether the query button renders with Scale9

void setpressedactionenabled (BOOL enabled)
Sets the zoom operation when the enabled button is pressed.

Virtual std::string getdescription () const override
Returns the description of the control class

Label * Gettitlerenderer () const
Returns the internal caption renderer for the button.
void Settitlealignment (Texthalignment halignment, textvalignment valignment)
Set the text vertical and horizontal alignment of a caption

void Setzoomscale (float scale)
When the user presses a button, the button zooms to the Zoom button to the final zoom ratio equal to (button initial zoom + _zoomscale)

float Getzoomscale () const
Returns a zoom ratio

Cocos Code Research (+) Widget sub-category button learning notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.