cocos2dx版本号:cocos2d-x-3.2alpha0
cocostudio版本号:V1.4.0.1
1.将cocostudio生成的UI文件复制到项目Resources目录
2.加入头文件,加入命名空间
#include "cocos-ext.h"
#include "editor-support/cocostudio/CCSGUIReader.h"
#include "ui/CocosGUI.h"
using namespace ui;
3.加入现有项目到解决方式
cocos2dextensions
cocos2dcocoseditor-supportcocostudio
cocos2dcocosui
4.设置项目属性,加入包括文件夹
cocos2d
cocos2dcocoseditor-support
cocos2dcocoseditor-supportcocostudio
5.设置项目属性,加入引用项
6.加入UI代码
auto _uiLayer = Layer::create();
addChild(_uiLayer);
auto _widget = dynamic_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("DemoHead_UI.ExportJson"));
_uiLayer->addChild(_widget);