Cocos js Add button 1, cocosjs Add button

Source: Internet
Author: User

Cocos js Add button 1, cocosjs Add button

In the cocos2d-js you can add a Menu to add a variety of interactive things, ratio, text, etc.
However, if the button location distribution is uneven, it is not very convenient to use Menu, so you are looking for a more convenient way.
Then I think the ccui. Button in the cocos built-in example is my favorite method, so it is defined as follows:


Var Button = new ccui. Button ();
Button. setTouchEnabled (true );
Button. setPressedActionEnabled (true );
Button. loadTextures ("res/buttons.png", "res/buttons.png ","");
Button. x = 135;
Button. y = 240;
Button. addTouchEventListener (this. selected, this );
This. addChild (Button );

Then, when you run the program, the message "Uncaught ReferenceError: ccui is not defined" is displayed.

So how to define ccui. Button is correct? How do you define buttons without using Menu?

Is it not introduced to the module in project. json.
"Modules": ["cocos2d", "extensions"],

Thanks for solving the problem, and then I have something new that I don't understand.
-What modules are in the js engine and when to add them? I saw that the chipmunk physical engine was used when I was reading the parkol tutorial. I need to add corresponding modules, but it is not added in js-tests, but it can also run normally...
Where can I learn about modules?

ModuleConfig. json in frameworks

Related Article

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.