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