Import libcocosstudio, libextensions, and libgui
The newly created project is as follows:
Add existing project
Right-click the solution and perform the following operations:
Add the following three projects:
(Project path) \ cocos2d \ Cocos \ UI \ proj. Win32 \ libgui. vcxproj
(Project path) \ cocos2d \ Cocos \ Editor-support \ cocostudio \ proj. Win32 \ libcocosstudio. vcxproj
(Project path) \ cocos2d \ extensions \ proj. Win32 \ libextensions. vcxproj
After completion
Add reference:
Add an additional include directory to prevent header files from being introduced:
You need:
$ (Engineroot) Cocos \ Editor-support
$ (Engineroot) cocos
$ (Engineroot) Cocos \ audio \ include
$ (Engineroot) External
$ (Engineroot) external \ chipmunk \ include \ chipmunk
$ (Engineroot) Extensions
.. \ Classes
Compile the code!
Compilation errors and solutions:
1. The editor is not updated.
C: \ Program Files (x86) \ msbuild \ Microsoft. CPP \ v4.0 \ v120 \ microsoft.cpp.platform.tar gets (2010): Error msb8020: The build tools for Visual Studio (platform toolset = 'v100') cannot be found. to build using the v100 build tools, please install Visual Studio 2010 build tools. alternatively, you may upgrade to the current Visual Studio Tools by selecting the project menu or right-click the solution, and then selecting "upgrade solution... ".
Right-click the newly added project to update the VC ++ compiler. Note that there will be a (vs2010 ***) Prompt on the right side of the project name that reports this error. update it!
Project exported using cocosstudio.
#include "cocos2d.h"#include "cocostudio/CocoStudio.h"#include "ui/CocosGUI.h"using namespace cocos2d;using namespace cocostudio;using namespace ui;
When a newbie reads controls through a JSON file, pay attention to their parent-child relationship, or else it will crash.
// Load the resource auto uilayer = guireader: getinstance ()-> widgetfromjsonfile ("startui/startui. exportjson "); this-> addchild (uilayer); Auto BG = uilayer-> getchildbyname (" BG "); Auto button = (Button *) BG-> getchildbyname ("button"); button-> runaction (moveBy: Create (1, point (-111, 0); button-> addtoucheventlistener (this, toucheventselector (cocosstudio: onbutton ));
Compilation error and solution: Using namespace UI; if an error is reported, add using namespace cocos2d to the front.