cocostudio ui编辑器里面可以添加editorBox控件么

请教下,cocostudio ui编辑器里面可以添加editorBox控件么
最新回答
暧昧分熟゜

2024-10-23 08:05:46

需要包含文件及名字空间:
?

1
2
3

<ol><li>#include "cocostudio/CocoStudio.h"</li><li></li><li>#include "ui/CocosGUI.h"</li><li></li><li>using namespace cocos2d::ui;</li><li></li><li>using namespace cocostudio;
注:工程需要附加包含文件目录:$(EngineRoot)cocos\editor-supportcocostudio目录
</li></ol>

获取UI控件:

m_achievementLayer = dynamic_cast<layout*>(GUIReader::getInstance()->widgetFromJsonFile("achievements/achievements.json"));
addChild(m_achievementLayer);

Widget* scoreWidget = dynamic_cast<widget*>(m_achievementLayer->getChildByName("ImageView_231"));
m_score = dynamic_cast<textatlas*>(scoreWidget->getChildByName("LabelAtlas_307"));
m_score->setStringValue("45");</textatlas*></widget*></layout*>

添加按钮调事件

Button* startButton = dynamic_cast<button*>(m_achievementLayer->getChildByName("Button_336"));
startButton->addTouchEventListener(this, toucheventselector(GameScene::touchStartButton)); </button*>

利用addTouchEventListener函数绑定按钮调事件~

调函数实现:

void GameScene::touchStartButton(Ref* pSender, TouchEventType type)
{
switch (type)
{
case TOUCH_EVENT_ENDED:
//do something
break;
}
}