cocostudio ui编辑器的使用----代码部分1
来源:互联网 发布:三家运营商的网络制式 编辑:程序博客网 时间:2024/06/11 20:12
//将ui编辑器导出的json文件加入到项目中。
Layout *m_pBuild_root = static_cast<Layout*>(GUIReader::getInstance()->widgetFromJsonFile("Ui/BaseUi_8_1.json"));
this->addChild(m_pBuild_root);
//对ui编辑器中图片的处理
ImageView * buildImg = static_cast<ImageView*>(Helper::seekWidgetByName(m_pBuild_root, "build_img"));//get ImageView
buildImg->loadTexture("build.png"); //Load texture for imageview.
//对应文本框
Text* m_label = static_cast<Text*>(Helper::seekWidgetByName(m_pBuild_root,"Label_1"));
m_label->setText(Value("safds").getDescription().c_str()); //Changes the string value of label.
m_label->setColor(ccColor3B::RED);
int a=111;
int b=222;
int c=333;
//对应输入框
TextField * textfield= static_cast<TextField*>(Helper::seekWidgetByName(m_pBuild_root, "TextField_11"));
textfield->setText(Value(b).getDescription().c_str());
//对应数字标签
TextAtlas * atlas=static_cast<TextAtlas*>(Helper::seekWidgetByName(m_pBuild_root, "AtlasLabel_17"));
atlas->setStringValue(Value(c).getDescription().c_str());
//对应自定义字体
TextBMFont*bmf = static_cast<TextBMFont*>(Helper::seekWidgetByName(m_pBuild_root,"BitmapLabel_16"));
bmf->setText(Value(a).getDescription().c_str());
Tips:
1、层容器在ui编辑器中不提供锚点设置功能,默认为左下角,如需更改(如需要在项目中整体缩放)可在代码中更改锚点设置。
for (int i =1; i <7; i++)
{
Widget *panel=(Widget*)m_pBuild_root->getChildByTag(100);
Widget *panel2=(Widget*)panel->getChildByTag(i);
if (panel2!=NULL)
{
Rect rect=panel2->getBoundingBox();
Point pos=panel2->getPosition();
panel2->setAnchorPoint(Point(0.5,0.5));
panel2->setPosition(Point(pos.x+rect.size.width/2,pos.y+rect.size.height/2));
}
}
2、如果不想控件响应触摸事件,可在编辑器中关闭交互。
- cocostudio ui编辑器的使用----代码部分1
- CocoStudio UI 编辑器的使用
- CocoStudio UI编辑器的简单使用
- cocoStudio工具的使用-----UI编辑器
- 【CocoStudio游戏开发之三】使用Cocostudio UI编辑器篇
- 如何使用 CocoStudio UI 编辑器实现
- [cocos2dx笔记011]使用Cocostudio UI编辑器
- CocoStudio UI编辑器基础
- 如何使用 CocoStudio UI 编辑器实现《乱斗堂》设置界面
- 加载cocostudio导出的场景后,如何在代码里获取ui组件,ui组件是ui编辑器导出后用于场景编辑器。
- CocoStudio 《UI编辑器》 教程(转)
- cocoStudio UI编辑器 学习总结
- CocoStudio UI编辑器 学习总结
- cocoStudio UI编辑器 学习总结
- cocoStudio UI编辑器 学习总结
- CocoStudio UI编辑器自定义插件
- CocoStudio 数据编辑器的使用教程
- cocoStudio工具的使用-----场景编辑器
- ObjectARX向导安装路径问题及解决方案
- windows 命令行中使用winrar
- [GEiv]第一章:静态绘制(三) 转置、尺度变换与混合通道
- 线性时间的桶排序介绍与理解(含c源代码)
- 网卡驱动注册到PCI总线这一过程的分析二
- cocostudio ui编辑器的使用----代码部分1
- Linux keepalived与lvs的深入分析
- 分布式和集群的概念
- Nginx配置参数说明
- redis 2.6.9安装报错解决
- 删除链表节点
- 有趣的C语言问答
- Intent MIME type介绍
- vision引擎中 地形几何网格导出